Options
All
  • Public
  • Public/Protected
  • All
Menu

A universal resource identifier representing either a file on disk or another resource, like untitled resources.

Hierarchy

  • Uri

Index

Constructors

  • new Uri(scheme: string, authority: string, path: string, query: string, fragment: string): Uri
  • Use the file and parse factory functions to create new Uri objects.

    Parameters

    • scheme: string
    • authority: string
    • path: string
    • query: string
    • fragment: string

    Returns Uri

Properties

authority: string

Authority is the www.msft.com part of http://www.msft.com/some/path?query#fragment. The part between the first double slashes and the next slash.

fragment: string

Fragment is the fragment part of http://www.msft.com/some/path?query#fragment.

fsPath: string

The string representing the corresponding file system path of this Uri.

Will handle UNC paths and normalize windows drive letters to lower-case. Also uses the platform specific path separator. Will not validate the path for invalid characters and semantics. Will not look at the scheme of this Uri.

path: string

Path is the /some/path part of http://www.msft.com/some/path?query#fragment.

query: string

Query is the query part of http://www.msft.com/some/path?query#fragment.

scheme: string

Scheme is the http part of http://www.msft.com/some/path?query#fragment. The part before the first colon.

Methods

  • toJSON(): any
  • toString(skipEncoding?: boolean): string
  • Returns a string representation of this Uri. The representation and normalization of a URI depends on the scheme. The resulting string can be safely used with Uri.parse.

    Parameters

    • Optional skipEncoding: boolean

      Do not percentage-encode the result, defaults to false. Note that the # and ? characters occurring in the path will always be encoded.

    Returns string

    A string representation of this Uri.

  • with(change: { authority?: string; fragment?: string; path?: string; query?: string; scheme?: string }): Uri
  • Derive a new Uri from this Uri.

    let file = Uri.parse('before:some/file/path');
    let other = file.with({ scheme: 'after' });
    assert.ok(other.toString() === 'after:some/file/path');

    Parameters

    • change: { authority?: string; fragment?: string; path?: string; query?: string; scheme?: string }

      An object that describes a change to this Uri. To unset components use null or the empty string.

      • Optional authority?: string
      • Optional fragment?: string
      • Optional path?: string
      • Optional query?: string
      • Optional scheme?: string

    Returns Uri

    A new Uri that reflects the given change. Will return this Uri if the change is not changing anything.

  • file(path: string): Uri
  • from(components: { authority?: string; fragment?: string; path?: string; query?: string; scheme: string }): Uri
  • Create an URI from its component parts

    see

    Uri.toString

    Parameters

    • components: { authority?: string; fragment?: string; path?: string; query?: string; scheme: string }

      The component parts of an Uri.

      • Optional Readonly authority?: string
      • Optional Readonly fragment?: string
      • Optional Readonly path?: string
      • Optional Readonly query?: string
      • Readonly scheme: string

    Returns Uri

    A new Uri instance.

  • joinPath(uri: Uri, ...pathSegments: string[]): Uri
  • Create a new uri which path is the result of joining the path of the base uri with the provided path segments.

    • Note 1: joinPath only affects the path component and all other components (scheme, authority, query, and fragment) are left as they are.
    • Note 2: The base uri must have a path; an error is thrown otherwise.

    The path segments are normalized in the following ways:

    • sequences of path separators (/ or \) are replaced with a single separator
    • for file-uris on windows, the backslash-character (\) is considered a path-separator
    • the ..-segment denotes the parent segment, the . denotes the current segment
    • paths have a root which always remains, for instance on windows drive-letters are roots so that is true: joinPath(Uri.file('file:///c:/root'), '../../other').fsPath === 'c:/other'

    Parameters

    • uri: Uri
    • Rest ...pathSegments: string[]

      One more more path fragments

    Returns Uri

    A new uri which path is joined with the given fragments

  • parse(value: string): Uri
  • Create an URI from a string. Will throw if the given value is not valid.

    Parameters

    • value: string

      The string value of an Uri.

    Returns Uri

    A new Uri instance.