Projekt

Obecné

Profil

Stáhnout (3.74 KB) Statistiky
| Větev: | Revize:
1
declare module "url" {
2
    import { ParsedUrlQuery, ParsedUrlQueryInput } from 'querystring';
3

    
4
    // Input to `url.format`
5
    interface UrlObject {
6
        auth?: string | null;
7
        hash?: string | null;
8
        host?: string | null;
9
        hostname?: string | null;
10
        href?: string | null;
11
        pathname?: string | null;
12
        protocol?: string | null;
13
        search?: string | null;
14
        slashes?: boolean | null;
15
        port?: string | number | null;
16
        query?: string | null | ParsedUrlQueryInput;
17
    }
18

    
19
    // Output of `url.parse`
20
    interface Url {
21
        auth: string | null;
22
        hash: string | null;
23
        host: string | null;
24
        hostname: string | null;
25
        href: string;
26
        path: string | null;
27
        pathname: string | null;
28
        protocol: string | null;
29
        search: string | null;
30
        slashes: boolean | null;
31
        port: string | null;
32
        query: string | null | ParsedUrlQuery;
33
    }
34

    
35
    interface UrlWithParsedQuery extends Url {
36
        query: ParsedUrlQuery;
37
    }
38

    
39
    interface UrlWithStringQuery extends Url {
40
        query: string | null;
41
    }
42

    
43
    function parse(urlStr: string): UrlWithStringQuery;
44
    function parse(urlStr: string, parseQueryString: false | undefined, slashesDenoteHost?: boolean): UrlWithStringQuery;
45
    function parse(urlStr: string, parseQueryString: true, slashesDenoteHost?: boolean): UrlWithParsedQuery;
46
    function parse(urlStr: string, parseQueryString: boolean, slashesDenoteHost?: boolean): Url;
47

    
48
    function format(URL: URL, options?: URLFormatOptions): string;
49
    function format(urlObject: UrlObject | string): string;
50
    function resolve(from: string, to: string): string;
51

    
52
    function domainToASCII(domain: string): string;
53
    function domainToUnicode(domain: string): string;
54

    
55
    /**
56
     * This function ensures the correct decodings of percent-encoded characters as
57
     * well as ensuring a cross-platform valid absolute path string.
58
     * @param url The file URL string or URL object to convert to a path.
59
     */
60
    function fileURLToPath(url: string | URL): string;
61

    
62
    /**
63
     * This function ensures that path is resolved absolutely, and that the URL
64
     * control characters are correctly encoded when converting into a File URL.
65
     * @param url The path to convert to a File URL.
66
     */
67
    function pathToFileURL(url: string): URL;
68

    
69
    interface URLFormatOptions {
70
        auth?: boolean;
71
        fragment?: boolean;
72
        search?: boolean;
73
        unicode?: boolean;
74
    }
75

    
76
    class URL {
77
        constructor(input: string, base?: string | URL);
78
        hash: string;
79
        host: string;
80
        hostname: string;
81
        href: string;
82
        readonly origin: string;
83
        password: string;
84
        pathname: string;
85
        port: string;
86
        protocol: string;
87
        search: string;
88
        readonly searchParams: URLSearchParams;
89
        username: string;
90
        toString(): string;
91
        toJSON(): string;
92
    }
93

    
94
    class URLSearchParams implements Iterable<[string, string]> {
95
        constructor(init?: URLSearchParams | string | { [key: string]: string | string[] | undefined } | Iterable<[string, string]> | Array<[string, string]>);
96
        append(name: string, value: string): void;
97
        delete(name: string): void;
98
        entries(): IterableIterator<[string, string]>;
99
        forEach(callback: (value: string, name: string, searchParams: this) => void): void;
100
        get(name: string): string | null;
101
        getAll(name: string): string[];
102
        has(name: string): boolean;
103
        keys(): IterableIterator<string>;
104
        set(name: string, value: string): void;
105
        sort(): void;
106
        toString(): string;
107
        values(): IterableIterator<string>;
108
        [Symbol.iterator](): IterableIterator<[string, string]>;
109
    }
110
}
(40-40/45)