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