Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
175ab4aa
V
vscode
项目概览
掘金者说
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
175ab4aa
编写于
10月 24, 2019
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
don't warn when fixing missing scheme, just do it... bring back strict mode for parse
上级
666ad41b
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
22 addition
and
9 deletion
+22
-9
src/vs/base/common/uri.ts
src/vs/base/common/uri.ts
+11
-5
src/vs/base/test/node/uri.test.ts
src/vs/base/test/node/uri.test.ts
+5
-0
src/vs/monaco.d.ts
src/vs/monaco.d.ts
+3
-1
src/vs/vscode.d.ts
src/vs/vscode.d.ts
+2
-2
src/vs/workbench/api/common/extHostTypeConverters.ts
src/vs/workbench/api/common/extHostTypeConverters.ts
+1
-1
未找到文件。
src/vs/base/common/uri.ts
浏览文件 @
175ab4aa
...
...
@@ -41,10 +41,14 @@ function _validateUri(ret: URI): void {
}
// graceful behaviour when scheme is missing: fallback to using 'file'-scheme
function
_schemeFix
(
scheme
:
string
):
string
{
function
_schemeFix
(
scheme
:
string
,
strict
?:
boolean
):
string
{
if
(
!
scheme
)
{
console
.
trace
(
'
BAD uri lacks scheme, falling back to file-scheme.
'
);
scheme
=
'
file
'
;
if
(
strict
)
{
throw
new
Error
(
'
[UriError]: A scheme must be provided
'
);
}
else
{
// console.trace('BAD uri lacks scheme, falling back to file-scheme.');
scheme
=
'
file
'
;
}
}
return
scheme
;
}
...
...
@@ -263,15 +267,17 @@ export class URI implements UriComponents {
* Creates a new URI from a string, e.g. `http://www.msft.com/some/path`,
* `file:///usr/home`, or `scheme:with/path`.
*
* *Note:* When the input lacks a scheme then `file` is used.
*
* @param value A string which represents an URI (see `URI#toString`).
*/
static
parse
(
value
:
string
):
URI
{
static
parse
(
value
:
string
,
strict
?:
boolean
):
URI
{
const
match
=
_uriRegExp
.
exec
(
value
);
if
(
!
match
)
{
throw
new
Error
(
`[UriError]: Invalid input:
${
value
}
`
);
}
const
scheme
=
_schemeFix
(
match
[
MatchIndex
.
scheme
])
||
''
;
const
scheme
=
_schemeFix
(
match
[
MatchIndex
.
scheme
]
,
strict
)
||
''
;
const
authority
=
match
[
MatchIndex
.
authority
]
||
''
;
const
path
=
_referenceResolution
(
scheme
,
match
[
MatchIndex
.
path
]
||
''
);
const
query
=
match
[
MatchIndex
.
query
]
||
''
;
...
...
src/vs/base/test/node/uri.test.ts
浏览文件 @
175ab4aa
...
...
@@ -235,6 +235,11 @@ suite('URI', () => {
assert
.
throws
(()
=>
URI
.
parse
(
'
file:////shares/files/p.cs
'
));
});
test
(
'
URI#parse, missing scheme
'
,
()
=>
{
assert
.
throws
(()
=>
URI
.
parse
(
'
/foo/bar
'
,
true
));
assertToString
(
'
/foo/bar
'
,
'
file:///foo/bar
'
);
});
test
(
'
URI#file, win-speciale
'
,
()
=>
{
if
(
isWindows
)
{
let
value
=
URI
.
file
(
'
c:
\\
test
\\
drive
'
);
...
...
src/vs/monaco.d.ts
浏览文件 @
175ab4aa
...
...
@@ -129,9 +129,11 @@ declare namespace monaco {
* Creates a new Uri from a string, e.g. `http://www.msft.com/some/path`,
* `file:///usr/home`, or `scheme:with/path`.
*
* *Note:* When the input lacks a scheme then `file` is used.
*
* @param value A string which represents an Uri (see `Uri#toString`).
*/
static
parse
(
value
:
string
):
Uri
;
static
parse
(
value
:
string
,
strict
?:
boolean
):
Uri
;
/**
* Creates a new Uri from a file system path, e.g. `c:\my\files`,
* `/usr/home`, or `\\server\share\some\path`.
...
...
src/vs/vscode.d.ts
浏览文件 @
175ab4aa
...
...
@@ -1236,8 +1236,8 @@ declare module 'vscode' {
* `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)`
* as all uris should have a scheme.
When missing the `file`-scheme is being used unless
*
the `strict`-argument is `true` in which case an error is thrown.
*
* @see [Uri.toString](#Uri.toString)
* @param value The string value of an Uri.
...
...
src/vs/workbench/api/common/extHostTypeConverters.ts
浏览文件 @
175ab4aa
...
...
@@ -260,7 +260,7 @@ export namespace MarkdownString {
const
collectUri
=
(
href
:
string
):
string
=>
{
try
{
let
uri
=
URI
.
parse
(
href
);
let
uri
=
URI
.
parse
(
href
,
true
);
uri
=
uri
.
with
({
query
:
_uriMassage
(
uri
.
query
,
resUris
)
});
resUris
[
href
]
=
uri
;
}
catch
(
e
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录