Skip to main content

Class: Uri

Resource identifier for a resource

Constructors

new Uri()

private new Uri(scheme, authority, path, query, fragment): 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

Source

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

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.

Source

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


fragment

readonly fragment: string

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

Source

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


fsPath

readonly fsPath: string

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

Source

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


path

readonly path: string

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

Source

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


query

readonly query: string

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

Source

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


scheme

readonly scheme: string

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

Source

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

Methods

toString()

toString(): string

Returns

string

Source

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


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.

Source

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


file()

static file(path): Uri

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

Parameters

path: string

Returns

Uri

Source

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


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

Source

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


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

Source

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