1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
|
// Type definitions for url-parse 1.4
// Project: https://github.com/unshiftio/url-parse
// Definitions by: Pavlo Chernenko <https://github.com/ChernenkoPaul>
// Hari Sivaramakrishnan <https://github.com/harisiva>
// Dmitry Dushkin <https://github.com/DimitryDushkin>
// David Golightly <https://github.com/davidgoli>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
declare namespace URLParse {
type URLPart = 'auth'
| 'hash'
| 'host'
| 'hostname'
| 'href'
| 'origin'
| 'password'
| 'pathname'
| 'port'
| 'protocol'
| 'query'
| 'slashes'
| 'username';
type QueryParser = (query: string) => object;
type StringifyQuery = (query: object) => string;
}
interface URLParse {
readonly auth: string;
readonly hash: string;
readonly host: string;
readonly hostname: string;
readonly href: string;
readonly origin: string;
readonly password: string;
readonly pathname: string;
readonly port: string;
readonly protocol: string;
readonly query: { [key: string]: string | undefined };
readonly slashes: boolean;
readonly username: string;
set(part: URLParse.URLPart, value: string | object | number | undefined, fn?: boolean | URLParse.QueryParser): URLParse;
toString(stringify?: URLParse.StringifyQuery): string;
}
declare const URLParse: {
new(address: string, parser?: boolean | URLParse.QueryParser): URLParse;
new(address: string, location?: string | object, parser?: boolean | URLParse.QueryParser): URLParse;
(address: string, parser?: boolean | URLParse.QueryParser): URLParse;
(address: string, location?: string | object, parser?: boolean | URLParse.QueryParser): URLParse;
extractProtocol(url: string): {
slashes: boolean;
protocol: string;
rest: string;
};
location(url: string): object;
qs: {
parse: URLParse.QueryParser;
stringify: URLParse.StringifyQuery;
};
};
export = URLParse;
|