Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
bea884b9
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,发现更多精彩内容 >>
提交
bea884b9
编写于
10月 23, 2019
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
polish
上级
a7c1ece7
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
33 addition
and
20 deletion
+33
-20
src/vs/base/common/uri.ts
src/vs/base/common/uri.ts
+33
-20
未找到文件。
src/vs/base/common/uri.ts
浏览文件 @
bea884b9
...
...
@@ -375,7 +375,7 @@ export class URI implements UriComponents {
* @param skipEncoding Do not encode the result, default is `false`
*/
toString
(
skipEncoding
:
boolean
=
false
):
string
{
return
_toString
(
skipEncoding
?
minialEncode
:
normalEncode
,
this
.
scheme
,
this
.
authority
,
this
.
path
,
this
.
query
,
this
.
fragment
);
return
_toString
(
skipEncoding
?
mini
m
alEncode
:
normalEncode
,
this
.
scheme
,
this
.
authority
,
this
.
path
,
this
.
query
,
this
.
fragment
);
}
toJSON
():
UriComponents
{
...
...
@@ -433,7 +433,7 @@ class _URI extends URI {
toString
(
skipEncoding
:
boolean
=
false
):
string
{
if
(
skipEncoding
)
{
// we don't cache that
return
_toString
(
minialEncode
,
this
.
scheme
,
this
.
authority
,
this
.
path
,
this
.
query
,
this
.
fragment
);
return
_toString
(
mini
m
alEncode
,
this
.
scheme
,
this
.
authority
,
this
.
path
,
this
.
query
,
this
.
fragment
);
}
if
(
!
this
.
_formatted
)
{
this
.
_formatted
=
_toString
(
normalEncode
,
this
.
scheme
,
this
.
authority
,
this
.
path
,
this
.
query
,
this
.
fragment
);
...
...
@@ -527,8 +527,8 @@ function percentDecode(str: string): string {
//#region ---- encode
// https://url.spec.whatwg.org/#percent-encoded-bytes
// "The C0 control percent-encode set are the C0 controls and all code points greater than U+007E (~)."
// "The C0 control percent-encode set are the C0 controls and all code points greater than U+007E (~)."
function
isC0ControlPercentEncodeSet
(
code
:
number
):
boolean
{
return
code
<=
0x1F
||
code
>
0x7E
;
}
...
...
@@ -566,28 +566,41 @@ function isLowerAsciiHex(code: number): boolean {
||
code
>=
CharCode
.
a
&&
code
<=
CharCode
.
z
;
}
const
_encodeTable
:
string
[]
=
(
function
()
{
let
table
:
string
[]
=
[];
for
(
let
code
=
0
;
code
<
128
;
code
++
)
{
table
[
code
]
=
`%
${
code
.
toString
(
16
)}
`
;
}
return
table
;
})();
function
percentEncode
(
str
:
string
,
mustEncode
:
(
code
:
number
)
=>
boolean
):
string
{
let
lazyOutStr
:
string
|
undefined
;
for
(
let
i
=
0
;
i
<
str
.
length
;
i
++
)
{
const
code
=
str
.
charCodeAt
(
i
);
for
(
let
pos
=
0
;
pos
<
str
.
length
;
pos
++
)
{
const
code
=
str
.
charCodeAt
(
pos
);
// invoke encodeURIComponent when needed
if
(
mustEncode
(
code
))
{
if
(
!
lazyOutStr
)
{
lazyOutStr
=
str
.
substr
(
0
,
i
);
lazyOutStr
=
str
.
substr
(
0
,
pos
);
}
//
if
(
isHighSurrogate
(
code
))
{
if
(
i
+
1
<
str
.
length
&&
isLowSurrogate
(
str
.
charCodeAt
(
i
+
1
)))
{
lazyOutStr
+=
encodeURIComponent
(
str
.
substr
(
i
,
2
));
i
+=
1
;
// Append encoded version of this surrogate pair (2 characters)
if
(
pos
+
1
<
str
.
length
&&
isLowSurrogate
(
str
.
charCodeAt
(
pos
+
1
)))
{
lazyOutStr
+=
encodeURIComponent
(
str
.
substr
(
pos
,
2
));
pos
+=
1
;
}
else
{
// broken surrogate pair
lazyOutStr
+=
str
.
charAt
(
i
);
lazyOutStr
+=
str
.
charAt
(
pos
);
}
}
else
{
// todo@joh PERF, use lookup table
lazyOutStr
+=
encodeURIComponent
(
str
.
charAt
(
i
));
// Append encoded version of the current character, use lookup table
// to speed up repeated encoding of the same characters.
if
(
code
<
_encodeTable
.
length
)
{
lazyOutStr
+=
_encodeTable
[
code
];
}
else
{
lazyOutStr
+=
encodeURIComponent
(
str
.
charAt
(
pos
));
}
}
continue
;
}
...
...
@@ -595,20 +608,20 @@ function percentEncode(str: string, mustEncode: (code: number) => boolean): stri
// normalize percent encoded sequences to upper case
// todo@joh also changes invalid sequences
if
(
code
===
CharCode
.
PercentSign
&&
i
+
2
<
str
.
length
&&
(
isLowerAsciiHex
(
str
.
charCodeAt
(
i
+
1
))
||
isLowerAsciiHex
(
str
.
charCodeAt
(
i
+
2
)))
&&
pos
+
2
<
str
.
length
&&
(
isLowerAsciiHex
(
str
.
charCodeAt
(
pos
+
1
))
||
isLowerAsciiHex
(
str
.
charCodeAt
(
pos
+
2
)))
)
{
if
(
!
lazyOutStr
)
{
lazyOutStr
=
str
.
substr
(
0
,
i
);
lazyOutStr
=
str
.
substr
(
0
,
pos
);
}
lazyOutStr
+=
'
%
'
+
str
.
substr
(
i
+
1
,
2
).
toUpperCase
();
i
+=
2
;
lazyOutStr
+=
'
%
'
+
str
.
substr
(
pos
+
1
,
2
).
toUpperCase
();
pos
+=
2
;
continue
;
}
// once started, continue to build up lazy output
if
(
lazyOutStr
)
{
lazyOutStr
+=
str
.
charAt
(
i
);
lazyOutStr
+=
str
.
charAt
(
pos
);
}
}
return
lazyOutStr
||
str
;
...
...
@@ -618,7 +631,7 @@ const enum EncodePart {
user
,
authority
,
path
,
query
,
fragment
}
const
normalEncode
:
{
(
code
:
number
):
boolean
}[]
=
[
isUserInfoPercentEncodeSet
,
isC0ControlPercentEncodeSet
,
isPathPercentEncodeSet
,
isFragmentPercentEncodeSet
,
isQueryPrecentEncodeSet
];
const
minialEncode
:
{
(
code
:
number
):
boolean
}[]
=
[
isHashOrQuestionMark
,
isHashOrQuestionMark
,
isHashOrQuestionMark
,
isHashOrQuestionMark
,
()
=>
false
];
const
mini
m
alEncode
:
{
(
code
:
number
):
boolean
}[]
=
[
isHashOrQuestionMark
,
isHashOrQuestionMark
,
isHashOrQuestionMark
,
isHashOrQuestionMark
,
()
=>
false
];
/**
* Create the external version of a uri
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录