Skip to main content

Class: Uri

Defined in: packages/extension-api/src/extension-api.d.ts:1893

Resource identifier for a resource

Properties​

authority​

readonly authority: string

Defined in: packages/extension-api/src/extension-api.d.ts:1940

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


fragment​

readonly fragment: string

Defined in: packages/extension-api/src/extension-api.d.ts:1960

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


fsPath​

readonly fsPath: string

Defined in: packages/extension-api/src/extension-api.d.ts:1950

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


path​

readonly path: string

Defined in: packages/extension-api/src/extension-api.d.ts:1945

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


query​

readonly query: string

Defined in: packages/extension-api/src/extension-api.d.ts:1955

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


scheme​

readonly scheme: string

Defined in: packages/extension-api/src/extension-api.d.ts:1934

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

Methods​

toString()​

toString(): string

Defined in: packages/extension-api/src/extension-api.d.ts:1999

Returns​

string


with()​

with(change): Uri

Defined in: packages/extension-api/src/extension-api.d.ts:1976

Derive a new Uri from this Uri.

const foo = Uri.parse('http://foo');
const httpsFoo = foo.with({ scheme: 'https' });
// httpsFoo is now 'https://foo'

Parameters​

change​

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

authority?​

string

The new authority, defaults to this Uri's authority.

fragment?​

string

The new fragment, defaults to this Uri's fragment.

path?​

string

The new path, defaults to this Uri's path.

query?​

string

The new query, defaults to this Uri's query.

scheme?​

string

The new scheme, defaults to this Uri's scheme.

Returns​

Uri

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


file()​

static file(path): Uri

Defined in: packages/extension-api/src/extension-api.d.ts:1913

Create an URI from a file system path. The scheme will be file.

Parameters​

path​

string

Returns​

Uri


joinPath()​

static joinPath(base, ...pathSegments): Uri

Defined in: packages/extension-api/src/extension-api.d.ts:1923

Create a new uri which path is the result of joining the path of the base uri with the provided path segments.

Parameters​

base​

Uri

An uri. Must have a path.

pathSegments​

...string[]

One more more path fragments

Returns​

Uri

A new uri which path is joined with the given fragments


parse()​

static parse(value, strict?): Uri

Defined in: packages/extension-api/src/extension-api.d.ts:1907

Create an URI from a string, e.g. http://www.example.com/some/path, file:///usr/home, or scheme:with/path.

Note that for a while uris without a scheme were accepted. That is not correct as all uris should have a scheme. To avoid breakage of existing code the optional strict-argument has been added. We strongly advise to use it, e.g. Uri.parse('my:uri', true)

Parameters​

value​

string

The string value of an Uri.

strict?​

boolean

Throw an error when value is empty or when no scheme can be parsed.

Returns​

Uri

A new Uri instance.

See​

Uri.toString