MCPcopy
hub / github.com/nestjs/nest / formatAddress

Method formatAddress

packages/core/nest-application.ts:356–377  ·  view source on GitHub ↗
(address: any)

Source from the content-addressed store, hash-verified

354 }
355
356 private formatAddress(address: any): string {
357 if (isString(address)) {
358 if (platform() === 'win32') {
359 return address;
360 }
361 const basePath = encodeURIComponent(address);
362 return `${this.getProtocol()}+unix://${basePath}`;
363 }
364
365 let host = this.host();
366 if (address && address.family === 'IPv6') {
367 if (host === '::') {
368 host = '[::1]';
369 } else {
370 host = `[${host}]`;
371 }
372 } else if (host === '0.0.0.0') {
373 host = '127.0.0.1';
374 }
375
376 return `${this.getProtocol()}://${host}:${address.port}`;
377 }
378
379 public setGlobalPrefix(prefix: string, options?: GlobalPrefixOptions): this {
380 this.config.setGlobalPrefix(prefix);

Callers 1

getUrlMethod · 0.95

Calls 3

getProtocolMethod · 0.95
hostMethod · 0.95
isStringFunction · 0.90

Tested by

no test coverage detected