跳转到主内容

类: Uri

定义于: packages/extension-api/src/extension-api.d.ts:1844

资源的标识符

属性

authority

readonly authority: string

定义于: packages/extension-api/src/extension-api.d.ts:1891

Authority 是 http://www.example.com/some/path?query#fragment 中的 www.example.com 部分。在第一个双斜杠和下一个斜杠之间的部分。


fragment

readonly fragment: string

定义于: packages/extension-api/src/extension-api.d.ts:1911

Fragment 是 http://www.example.com/some/path?query#fragment 中的 fragment 部分。


fsPath

readonly fsPath: string

定义于: packages/extension-api/src/extension-api.d.ts:1901

此 Uri 对应的文件系统路径的字符串表示。


path

readonly path: string

定义于: packages/extension-api/src/extension-api.d.ts:1896

Path 是 http://www.example.com/some/path?query#fragment 中的 /some/path 部分。


query

readonly query: string

定义于: packages/extension-api/src/extension-api.d.ts:1906

Query 是 http://www.example.com/some/path?query#fragment 中的 query 部分。


scheme

readonly scheme: string

定义于: packages/extension-api/src/extension-api.d.ts:1885

Scheme 是 http://www.example.com/some/path?query#fragment 中的 http 部分。在第一个冒号之前的部分。

方法

toString()

toString(): string

定义于: packages/extension-api/src/extension-api.d.ts:1950

返回

string


with()

with(change): Uri

定义于: packages/extension-api/src/extension-api.d.ts:1927

从此 Uri 派生一个新的 Uri。

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

参数

change

描述对此 Uri 的更改的对象。要取消设置组件,请使用 undefined 或空字符串。

authority?

string

新的 authority,默认为此 Uri 的 authority。

fragment?

string

新的 fragment,默认为此 Uri 的 fragment。

path?

string

新的 path,默认为此 Uri 的 path。

query?

string

新的 query,默认为此 Uri 的 query。

scheme?

string

新的 scheme,默认为此 Uri 的 scheme。

返回值

Uri

反映给定更改的新 Uri。如果更改未改变任何内容,则返回 this Uri。


file()

static file(path): Uri

定义于: packages/extension-api/src/extension-api.d.ts:1864

从文件系统路径创建 URI。 scheme 将为 file

参数

path

string

返回值

Uri


joinPath()

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

定义于: packages/extension-api/src/extension-api.d.ts:1874

创建新 URI,其路径是 base Uri 的路径与提供的路径段连接的结果。

参数

base

Uri

一个 Uri。必须有 path。

pathSegments

...string[]

一个或多个路径片段

返回值

Uri

路径已与给定片段连接的新 Uri


parse()

static parse(value, strict?): Uri

定义于: packages/extension-api/src/extension-api.d.ts:1858

从字符串创建 URI,例如 http://www.example.com/some/pathfile:///usr/homescheme:with/path

注意,一段时间以来,没有 scheme 的 URI 被接受。这是不正确的,因为所有 URI 都应该有一个 scheme。为了避免破坏现有代码,添加了可选的 strict 参数。我们强烈建议使用它,例如 Uri.parse('my:uri', true)

参数

value

string

Uri 的字符串值。

strict?

boolean

value 为空或无法解析 scheme 时,抛出错误。

返回值

Uri

新的 Uri 实例。

参见

Uri.toString