Skip to main content

Class: Uri

Resource identifier for a resource

Properties

authority

readonly authority: string

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.

Defined in

packages/extension-api/src/extension-api.d.ts:1605


fragment

readonly fragment: string

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

Defined in

packages/extension-api/src/extension-api.d.ts:1625


fsPath

readonly fsPath: string

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

Defined in

packages/extension-api/src/extension-api.d.ts:1615


path

readonly path: string

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

Defined in

packages/extension-api/src/extension-api.d.ts:1610


query

readonly query: string

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

Defined in

packages/extension-api/src/extension-api.d.ts:1620


scheme

readonly scheme: string

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

Defined in

packages/extension-api/src/extension-api.d.ts:1599

Methods

toString()

toString(): string

Returns

string

Defined in

packages/extension-api/src/extension-api.d.ts:1664


with()

with(change): Uri

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.

change.authority?: string

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

change.fragment?: string

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

change.path?: string

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

change.query?: string

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

change.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.

Defined in

packages/extension-api/src/extension-api.d.ts:1641


file()

static file(path): Uri

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

Parameters

path: string

Returns

Uri

Defined in

packages/extension-api/src/extension-api.d.ts:1578


joinPath()

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

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

Defined in

packages/extension-api/src/extension-api.d.ts:1588


parse()

static parse(value, strict?): Uri

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

Defined in

packages/extension-api/src/extension-api.d.ts:1572