UNPKG

web-dev-server

Version:

Node.js simple http server for common development or training purposes.

142 lines (141 loc) 5.41 kB
import { Request } from "../Request"; import { Response } from "../Response"; export declare class Url { /** * Http scheme: `"http:" | "https:"` * Example: `"http:"` * @todo: implement https requesting. */ protected scheme?: string; /** * `TRUE` if http scheme is `"https:"` */ protected secure?: boolean; /** * Application server name - domain without any port. * Example: `"localhost"` */ protected hostName?: string; /** * Application host with port if there is any. * Example: `"localhost:88"` */ protected host?: string; /** * Http port defined in requested URI if any, parsed by `url.parse()`. * Empty string if there is no port number in requested address.`. * Example: `"88" | ""` */ protected port?: string; /** * Parsed server name (domain without port) parts. * Example: `['any.content', 'example', 'co.uk'] | [NULL, NULL, 'localhost']` */ protected domainParts?: string[]; /** * `TRUE` if http port defined in requested URI (parsed by `url.parse()`). */ protected portDefined: boolean; /** * Requested path in from application root, never with query string. * Example: `"/products/page/2"` */ protected path?: string; /** * Uri query string without question mark. * Example: `"param-1=value-1&param-2=value-2&param-3[]=value-3-a&param-3[]=value-3-b"` */ protected query?: string; /** * Php requested script name path from application root. * Example: `"/index.js"` */ protected scriptName?: string; /** * Application root path on hard drive. * Example: `"C:/www/my/development/directory/www"` */ protected appRoot?: string; /** * Base app directory path after domain, if application is placed in domain subdirectory * Example: * - full URI: `"http://localhost:88/my/development/directory/www/requested/path/after/domain?with=possible&query=string"` * - base path: `"/my/development/directory/www"` */ protected basePath?: string; /** * Request path after domain with possible query string * Example: `"/requested/path/after/app/root?with=possible&query=string"` */ protected requestPath?: string; /** * Url to requested domain and possible port. * Example: `"https://domain.com" | "http://domain:88"` if any port. */ protected domainUrl?: string; /** * Base URI to application root. * Example: `"http://domain:88/my/development/directory/www"` */ protected baseUrl?: string; /** * Request URI including scheme, domain, port, path, without any query string * Example: "`http://localhost:88/my/development/directory/www/requested/path/after/domain"` */ protected requestUrl?: string; /** * Request URI including scheme, domain, port, path and with query string * Example: `"http://localhost:88/my/development/directory/www/requested/path/after/domain?with=possible&query=string"` */ protected fullUrl?: string; SetScriptName(scriptName: any): Request; GetScriptName(): string; SetAppRoot(appRoot: string): Request; GetAppRoot(): string; SetScheme(rawProtocol: string): Request; GetScheme(): string; IsSecure(): boolean; SetHostName(rawHostName: string): Request; GetHostName(): string; SetHost(rawHost: string): Request; GetHost(): string; SetPort(rawPort: string): Request; GetPort(): string; SetTopLevelDomain(topLevelDomain: string | null): Request; GetTopLevelDomain(): string | null; SetSecondLevelDomain(secondLevelDomain: string | null): Request; GetSecondLevelDomain(): string | null; SetThirdLevelDomain(thirdLevelDomain: string | null): Request; GetThirdLevelDomain(): string | null; SetBasePath(rawBasePath: string): Request; GetBasePath(): string; SetPath(rawPathValue: string): Request; GetPath(rawInput?: boolean): string; SetQuery(rawQuery: string): Request; GetQuery(withQuestionMark?: boolean, rawInput?: boolean): string; GetRequestPath(rawInput?: boolean): string; GetDomainUrl(rawInput?: boolean): string; GetBaseUrl(rawInput?: boolean): string; GetRequestUrl(rawInput?: boolean): string; GetFullUrl(rawInput?: boolean): string; /** * @summary Request set up method called before `index.js` script execution. * @param serverDocRoot * @param appRootFullPath * @param indexScript * @param serverBasePath */ protected setUpIndexScriptExec(serverDocRoot: string, appRootFullPath: string, indexScript: string, serverBasePath: string, response: Response): void; /** * Initialize URI segments parsed by `url.parse()`: path, query and fragment. */ protected initUrlSegments(appRoot: any, basePath: any, scriptName: any, requestPath: any): void; /** * Initialize domain parts from server name property. * If you need to add exceptional top-level domain names, use method * `Request.AddTwoSegmentTlds('co.uk');` * Example: * `'any.content.example.co.uk' => ['any.content', 'example', 'co.uk']` */ protected initDomainSegments(): void; }