Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
96aee260
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,发现更多精彩内容 >>
提交
96aee260
编写于
10月 23, 2019
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add tests that compare URI against nodejs/standard URL
上级
bea884b9
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
79 addition
and
6 deletion
+79
-6
src/vs/base/test/node/uri.test.ts
src/vs/base/test/node/uri.test.ts
+79
-6
未找到文件。
src/vs/base/test/node/uri.test.ts
浏览文件 @
96aee260
...
...
@@ -5,7 +5,7 @@
import
*
as
assert
from
'
assert
'
;
import
{
URI
,
UriComponents
}
from
'
vs/base/common/uri
'
;
import
{
isWindows
}
from
'
vs/base/common/platform
'
;
import
{
pathToFileURL
}
from
'
url
'
;
import
{
pathToFileURL
,
fileURLToPath
,
URL
}
from
'
url
'
;
suite
(
'
URI
'
,
()
=>
{
test
(
'
file#toString
'
,
()
=>
{
...
...
@@ -455,7 +455,7 @@ suite('URI', () => {
assert
.
equal
(
uri1
.
path
,
uri2
.
path
);
assert
.
equal
(
uri1
.
query
,
uri2
.
query
);
assert
.
equal
(
uri1
.
fragment
,
uri2
.
fragment
);
assert
.
equal
(
strIn
,
strOut
);
// fails here!!
assert
.
equal
(
strIn
,
strOut
);
});
test
(
'
Uri#parse can break path-component #45515
'
,
function
()
{
...
...
@@ -469,7 +469,7 @@ suite('URI', () => {
assert
.
equal
(
uri1
.
path
,
uri2
.
path
);
assert
.
equal
(
uri1
.
query
,
uri2
.
query
);
assert
.
equal
(
uri1
.
fragment
,
uri2
.
fragment
);
assert
.
equal
(
strIn
,
strOut
);
// fails here!!
assert
.
equal
(
strIn
,
strOut
);
});
test
(
'
URI - (de)serialize
'
,
function
()
{
...
...
@@ -502,14 +502,27 @@ suite('URI', () => {
// console.profileEnd();
});
function
assertFileUri
(
path
:
string
):
void
{
// check that our uri aligns with nodejs
// ------ check against standard URL and nodejs-file-url utils
function
assertFileUri
(
path
:
string
,
recurse
=
true
):
void
{
const
actual
=
URI
.
file
(
path
).
toString
();
const
expected
=
pathToFileURL
(
path
).
href
;
assert
.
equal
(
actual
,
expected
);
if
(
recurse
)
{
assertFsPath
(
expected
,
false
);
}
}
function
assertFsPath
(
uri
:
string
,
recurse
=
true
):
void
{
const
actual
=
URI
.
parse
(
uri
).
fsPath
;
const
expected
=
fileURLToPath
(
uri
);
assert
.
equal
(
actual
,
expected
);
if
(
recurse
)
{
assertFileUri
(
actual
,
false
);
}
}
test
(
'
URI.file
vs
pathToFileURL
'
,
function
()
{
test
(
'
URI.file
and
pathToFileURL
'
,
function
()
{
assertFileUri
(
'
/foo/bar
'
);
assertFileUri
(
'
/foo/%2e.txt
'
);
// %2e -> .
assertFileUri
(
'
/foo/%A0.txt
'
);
// %A0 -> invalid
...
...
@@ -520,4 +533,64 @@ suite('URI', () => {
assertFileUri
(
'
/c
\\
win
\\
path
'
);
}
});
test
(
'
URI.fsPath and fileURLToPath
'
,
function
()
{
assertFsPath
(
'
file:///foo/bar
'
);
assertFsPath
(
'
file:///fo%25/bar
'
);
assertFsPath
(
'
file:///foo/b ar/text.cs
'
);
assertFsPath
(
'
file:///foö/bar
'
);
assertFsPath
(
'
file:///fo%C3%B6/bar
'
);
assertFsPath
(
'
file:///
'
);
// assertFsPath('file:///fo%2f/bar'); not allowed in nodejs
if
(
isWindows
)
{
// nodejs doesn't create UNC-paths on non-windows
assertFsPath
(
'
file://unc-host/foö/bar
'
);
assertFsPath
(
'
file://unc-host/
'
);
// nodejs prepends c: with / on non-windows
assertFsPath
(
'
file:///c:/bar/foo
'
);
}
if
(
!
isWindows
)
{
//
assertFsPath
(
'
file:///foo%5cbar
'
);
assertFsPath
(
'
file:///foo%5Cbar
'
);
assertFsPath
(
'
file:///foo%5C%5cbar
'
);
}
});
function
assertToString
(
uri
:
string
):
void
{
const
actual
=
URI
.
parse
(
uri
).
toString
();
const
expected
=
new
URL
(
uri
).
href
;
assert
.
equal
(
actual
,
expected
);
}
test
(
'
URI.toString and URL.href
'
,
function
()
{
assertToString
(
'
before:some/file/path
'
);
assertToString
(
'
scheme://authority/path
'
);
assertToString
(
'
scheme:/path
'
);
assertToString
(
'
foo:bar/path
'
);
// assertToString('http:/api/files/test.me?t=1234'); // URL make api the hostname,
assertToString
(
'
http://api/files/test.me?t=1234
'
);
// assertToString('file:///c:/test/me'); // we encode the colon
// assertToString('file:///c:/Source/Z%C3%BCrich%20or%20Zurich%20(%CB%88zj%CA%8A%C9%99r%C9%AAk,/Code/resources/app/plugins/c%23/plugin.json');
// assertToString('file:///c:/test %25/path');
assertToString
(
'
file://shares/files/c%23/p.cs
'
);
assertToString
(
'
inmemory:
'
);
assertToString
(
'
foo:api/files/test
'
);
assertToString
(
'
file:?q
'
);
assertToString
(
'
file:#d
'
);
assertToString
(
'
f3ile:#d
'
);
assertToString
(
'
foo+bar:path
'
);
assertToString
(
'
foo-bar:path
'
);
assertToString
(
'
foo.bar:path
'
);
assertToString
(
'
file:///_:/path
'
);
assertToString
(
'
https://firebasestorage.googleapis.com/v0/b/brewlangerie.appspot.com/o/products%2FzVNZkudXJyq8bPGTXUxx%2FBetterave-Sesame.jpg?alt=media&token=0b2310c4-3ea6-4207-bbde-9c3710ba0437
'
);
assertToString
(
'
https://myhost.com/Redirect?url=http%3A%2F%2Fwww.bing.com%3Fsearch%3Dtom
'
);
assertToString
(
'
debug:internalModule.js?session=aDebugSessionId&ref=11
'
);
assertToString
(
'
debug:internalModule.js?session%3DaDebugSessionId%26ref%3D11
'
);
assertToString
(
'
https://github.com/microsoft/vscode/issues/33746#issuecomment-545345356
'
);
});
});
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录