2 * Uniform Resource Identifier (URI) http://tools.ietf.org/html/rfc3986.
3 * This class is a simple parser which creates the basic component parts
4 * (http://tools.ietf.org/html/rfc3986#section-3) with minimal validation
8 * foo://example.com:8042/over/there?name=ferret#nose
9 * \_/ \______________/\_________/ \_________/ \__/
11 * scheme authority path query fragment
12 * | _____________________|__
14 * urn:example:animal:ferret:nose
17 export declare class URI implements UriComponents {
18 static isUri(thing: any): thing is URI;
20 * scheme is the 'http' part of 'http://www.msft.com/some/path?query#fragment'.
21 * The part before the first colon.
23 readonly scheme: string;
25 * authority is the 'www.msft.com' part of 'http://www.msft.com/some/path?query#fragment'.
26 * The part between the first double slashes and the next slash.
28 readonly authority: string;
30 * path is the '/some/path' part of 'http://www.msft.com/some/path?query#fragment'.
32 readonly path: string;
34 * query is the 'query' part of 'http://www.msft.com/some/path?query#fragment'.
36 readonly query: string;
38 * fragment is the 'fragment' part of 'http://www.msft.com/some/path?query#fragment'.
40 readonly fragment: string;
44 protected constructor(scheme: string, authority?: string, path?: string, query?: string, fragment?: string, _strict?: boolean);
48 protected constructor(components: UriComponents);
50 * Returns a string representing the corresponding file system path of this URI.
51 * Will handle UNC paths, normalizes windows drive letters to lower-case, and uses the
52 * platform specific path separator.
54 * * Will *not* validate the path for invalid characters and semantics.
55 * * Will *not* look at the scheme of this URI.
56 * * The result shall *not* be used for display purposes but for accessing a file on disk.
59 * The *difference* to `URI#path` is the use of the platform specific separator and the handling
60 * of UNC paths. See the below sample of a file-uri with an authority (UNC path).
63 const u = URI.parse('file://server/c$/folder/file.txt')
64 u.authority === 'server'
65 u.path === '/shares/c$/file.txt'
66 u.fsPath === '\\server\c$\folder\file.txt'
69 * Using `URI#path` to read a file (using fs-apis) would not be enough because parts of the path,
70 * namely the server name, would be missing. Therefore `URI#fsPath` exists - it's sugar to ease working
71 * with URIs that represent files on disk (`file` scheme).
76 authority?: string | null;
78 query?: string | null;
79 fragment?: string | null;
82 * Creates a new URI from a string, e.g. `http://www.msft.com/some/path`,
83 * `file:///usr/home`, or `scheme:with/path`.
85 * @param value A string which represents an URI (see `URI#toString`).
87 static parse(value: string, _strict?: boolean): URI;
89 * Creates a new URI from a file system path, e.g. `c:\my\files`,
90 * `/usr/home`, or `\\server\share\some\path`.
92 * The *difference* between `URI#parse` and `URI#file` is that the latter treats the argument
93 * as path, not as stringified-uri. E.g. `URI.file(path)` is **not the same as**
94 * `URI.parse('file://' + path)` because the path might contain characters that are
95 * interpreted (# and ?). See the following sample:
97 const good = URI.file('/coding/c#/project1');
98 good.scheme === 'file';
99 good.path === '/coding/c#/project1';
100 good.fragment === '';
101 const bad = URI.parse('file://' + '/coding/c#/project1');
102 bad.scheme === 'file';
103 bad.path === '/coding/c'; // path is now broken
104 bad.fragment === '/project1';
107 * @param path A file system path (see `URI#fsPath`)
109 static file(path: string): URI;
110 static from(components: {
118 * Creates a string representation for this URI. It's guaranteed that calling
119 * `URI.parse` with the result of this function creates an URI which is equal
122 * * The result shall *not* be used for display purposes but for externalization or transport.
123 * * The result will be encoded using the percentage encoding and encoding happens mostly
124 * ignore the scheme-specific encoding rules.
126 * @param skipEncoding Do not encode the result, default is `false`
128 toString(skipEncoding?: boolean): string;
129 toJSON(): UriComponents;
130 static revive(data: UriComponents | URI): URI;
131 static revive(data: UriComponents | URI | undefined): URI | undefined;
132 static revive(data: UriComponents | URI | null): URI | null;
133 static revive(data: UriComponents | URI | undefined | null): URI | undefined | null;
135 export interface UriComponents {
143 * Compute `fsPath` for the given uri
145 export declare function uriToFsPath(uri: URI, keepDriveLetterCasing: boolean): string;