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