Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
2071e2fa
V
vscode
项目概览
xxadev
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
2071e2fa
编写于
6月 03, 2016
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
expose Uri#with to allow deriving a new Uri from an existing, #6678
上级
26caa263
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
55 addition
and
7 deletion
+55
-7
src/vs/base/common/uri.ts
src/vs/base/common/uri.ts
+26
-6
src/vs/base/test/common/uri.test.ts
src/vs/base/test/common/uri.test.ts
+15
-1
src/vs/vscode.d.ts
src/vs/vscode.d.ts
+14
-0
未找到文件。
src/vs/base/common/uri.ts
浏览文件 @
2071e2fa
...
@@ -133,12 +133,32 @@ export default class URI {
...
@@ -133,12 +133,32 @@ export default class URI {
// ---- modify to new -------------------------
// ---- modify to new -------------------------
public
with
(
change
:
{
scheme
?:
string
;
authority
?:
string
;
path
?:
string
;
query
?:
string
;
fragment
?:
string
}):
URI
{
public
with
(
change
:
{
scheme
?:
string
;
authority
?:
string
;
path
?:
string
;
query
?:
string
;
fragment
?:
string
}):
URI
{
var
ret
=
new
URI
();
ret
.
_scheme
=
change
.
scheme
||
this
.
scheme
;
if
(
!
change
)
{
ret
.
_authority
=
change
.
authority
||
this
.
authority
;
return
this
;
ret
.
_path
=
change
.
path
||
this
.
path
;
}
ret
.
_query
=
change
.
query
||
this
.
query
;
ret
.
_fragment
=
change
.
fragment
||
this
.
fragment
;
let
scheme
=
change
.
scheme
||
this
.
scheme
;
let
authority
=
change
.
authority
||
this
.
authority
;
let
path
=
change
.
path
||
this
.
path
;
let
query
=
change
.
query
||
this
.
query
;
let
fragment
=
change
.
fragment
||
this
.
fragment
;
if
(
scheme
===
this
.
scheme
&&
authority
===
this
.
authority
&&
path
===
this
.
path
&&
query
===
this
.
query
&&
fragment
===
this
.
fragment
)
{
return
this
;
}
const
ret
=
new
URI
();
ret
.
_scheme
=
scheme
;
ret
.
_authority
=
authority
;
ret
.
_path
=
path
;
ret
.
_query
=
query
;
ret
.
_fragment
=
fragment
;
URI
.
_validate
(
ret
);
URI
.
_validate
(
ret
);
return
ret
;
return
ret
;
}
}
...
...
src/vs/base/test/common/uri.test.ts
浏览文件 @
2071e2fa
...
@@ -62,7 +62,21 @@ suite('URI', () => {
...
@@ -62,7 +62,21 @@ suite('URI', () => {
assert
.
equal
(
uri2
.
fragment
,
uri3
.
fragment
);
assert
.
equal
(
uri2
.
fragment
,
uri3
.
fragment
);
});
});
test
(
'
with
'
,
()
=>
{
test
(
'
with, identity
'
,
()
=>
{
let
uri
=
URI
.
parse
(
'
foo:bar/path
'
);
let
uri2
=
uri
.
with
(
null
);
assert
.
ok
(
uri
===
uri2
);
uri2
=
uri
.
with
(
undefined
);
assert
.
ok
(
uri
===
uri2
);
uri2
=
uri
.
with
({});
assert
.
ok
(
uri
===
uri2
);
uri2
=
uri
.
with
({
scheme
:
'
foo
'
,
path
:
'
bar/path
'
});
assert
.
ok
(
uri
===
uri2
);
});
test
(
'
with, changes
'
,
()
=>
{
assert
.
equal
(
URI
.
parse
(
'
before:some/file/path
'
).
with
({
scheme
:
'
after
'
}).
toString
(),
'
after:some/file/path
'
);
assert
.
equal
(
URI
.
create
().
with
({
scheme
:
'
http
'
,
path
:
'
/api/files/test.me
'
,
query
:
'
t=1234
'
}).
toString
(),
'
http:/api/files/test.me?t%3D1234
'
);
assert
.
equal
(
URI
.
create
().
with
({
scheme
:
'
http
'
,
path
:
'
/api/files/test.me
'
,
query
:
'
t=1234
'
}).
toString
(),
'
http:/api/files/test.me?t%3D1234
'
);
assert
.
equal
(
URI
.
create
().
with
({
scheme
:
'
http
'
,
authority
:
''
,
path
:
'
/api/files/test.me
'
,
query
:
'
t=1234
'
,
fragment
:
''
}).
toString
(),
'
http:/api/files/test.me?t%3D1234
'
);
assert
.
equal
(
URI
.
create
().
with
({
scheme
:
'
http
'
,
authority
:
''
,
path
:
'
/api/files/test.me
'
,
query
:
'
t=1234
'
,
fragment
:
''
}).
toString
(),
'
http:/api/files/test.me?t%3D1234
'
);
assert
.
equal
(
URI
.
create
().
with
({
scheme
:
'
https
'
,
authority
:
''
,
path
:
'
/api/files/test.me
'
,
query
:
'
t=1234
'
,
fragment
:
''
}).
toString
(),
'
https:/api/files/test.me?t%3D1234
'
);
assert
.
equal
(
URI
.
create
().
with
({
scheme
:
'
https
'
,
authority
:
''
,
path
:
'
/api/files/test.me
'
,
query
:
'
t=1234
'
,
fragment
:
''
}).
toString
(),
'
https:/api/files/test.me?t%3D1234
'
);
...
...
src/vs/vscode.d.ts
浏览文件 @
2071e2fa
...
@@ -937,6 +937,20 @@ declare namespace vscode {
...
@@ -937,6 +937,20 @@ declare namespace vscode {
*/
*/
fsPath
:
string
;
fsPath
:
string
;
/**
* Derive a new Uri from this Uri.
*
* @param change An object that describes a change.
* @return A new Uri that reflects the changes. Will return `this` Uri if the change
* is not changing anything.
* @sample ```
let file = Uri.parse('before:some/file/path');
let other = file.with({ scheme: 'after' });
assert.ok(other.toString() === 'after:some/file/path');
* ```
*/
with
(
change
:
{
scheme
?:
string
;
authority
?:
string
;
path
?:
string
;
query
?:
string
;
fragment
?:
string
}):
Uri
;
/**
/**
* Returns a string representation of this Uri. The representation and normalization
* 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
* of a URI depends on the scheme. The resulting string can be safely used with
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录