Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
65cb3397
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,体验更适合开发者的 AI 搜索 >>
提交
65cb3397
编写于
4月 01, 2016
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
flip boolean, expose `skipEncoding` in API
上级
4e5950f1
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
30 addition
and
25 deletion
+30
-25
src/vs/base/common/uri.ts
src/vs/base/common/uri.ts
+12
-10
src/vs/base/test/common/uri.test.ts
src/vs/base/test/common/uri.test.ts
+8
-8
src/vs/vscode.d.ts
src/vs/vscode.d.ts
+9
-6
src/vs/workbench/services/editor/browser/editorService.ts
src/vs/workbench/services/editor/browser/editorService.ts
+1
-1
未找到文件。
src/vs/base/common/uri.ts
浏览文件 @
65cb3397
...
...
@@ -255,21 +255,23 @@ export default class URI {
/**
*
* @param
encode Encode the result, default is `true`.
* @param
skipEncoding Do not encode the result, default is `false`
*/
public
toString
(
encode
:
boolean
=
true
):
string
{
if
(
!
encode
)
{
return
URI
.
_asFormatted
(
this
,
false
);
}
if
(
!
this
.
_formatted
)
{
this
.
_formatted
=
URI
.
_asFormatted
(
this
,
true
);
public
toString
(
skipEncoding
:
boolean
=
false
):
string
{
if
(
!
skipEncoding
)
{
if
(
!
this
.
_formatted
)
{
this
.
_formatted
=
URI
.
_asFormatted
(
this
,
false
);
}
return
this
.
_formatted
;
}
else
{
// we don't cache that
return
URI
.
_asFormatted
(
this
,
true
);
}
return
this
.
_formatted
;
}
private
static
_asFormatted
(
uri
:
URI
,
encode
:
boolean
):
string
{
private
static
_asFormatted
(
uri
:
URI
,
skipEncoding
:
boolean
):
string
{
const
encoder
=
encode
const
encoder
=
!
skipEncoding
?
encodeURIComponent2
:
encodeNoop
;
...
...
src/vs/base/test/common/uri.test.ts
浏览文件 @
65cb3397
...
...
@@ -43,19 +43,19 @@ suite('URI', () => {
});
test
(
'
http#toString, encode=FALSE
'
,
()
=>
{
assert
.
equal
(
URI
.
create
(
'
http
'
,
'
a-test-site.com
'
,
'
/
'
,
'
test=true
'
).
toString
(
fals
e
),
'
http://a-test-site.com/?test=true
'
);
assert
.
equal
(
URI
.
create
(
'
http
'
,
'
a-test-site.com
'
,
'
/
'
,
''
,
'
test=true
'
).
toString
(
fals
e
),
'
http://a-test-site.com/#test=true
'
);
assert
.
equal
(
URI
.
create
().
withScheme
(
'
http
'
).
withPath
(
'
/api/files/test.me
'
).
withQuery
(
'
t=1234
'
).
toString
(
fals
e
),
'
http:/api/files/test.me?t=1234
'
);
assert
.
equal
(
URI
.
create
(
'
http
'
,
'
a-test-site.com
'
,
'
/
'
,
'
test=true
'
).
toString
(
tru
e
),
'
http://a-test-site.com/?test=true
'
);
assert
.
equal
(
URI
.
create
(
'
http
'
,
'
a-test-site.com
'
,
'
/
'
,
''
,
'
test=true
'
).
toString
(
tru
e
),
'
http://a-test-site.com/#test=true
'
);
assert
.
equal
(
URI
.
create
().
withScheme
(
'
http
'
).
withPath
(
'
/api/files/test.me
'
).
withQuery
(
'
t=1234
'
).
toString
(
tru
e
),
'
http:/api/files/test.me?t=1234
'
);
var
value
=
URI
.
parse
(
'
file://shares/pröjects/c%23/#l12
'
);
assert
.
equal
(
value
.
authority
,
'
shares
'
);
assert
.
equal
(
value
.
path
,
'
/pröjects/c#/
'
);
assert
.
equal
(
value
.
fragment
,
'
l12
'
);
assert
.
equal
(
value
.
toString
(),
'
file://shares/pr%C3%B6jects/c%23/#l12
'
);
assert
.
equal
(
value
.
toString
(
fals
e
),
'
file://shares/pröjects/c%23/#l12
'
);
assert
.
equal
(
value
.
toString
(
tru
e
),
'
file://shares/pröjects/c%23/#l12
'
);
var
uri2
=
URI
.
parse
(
value
.
toString
(
fals
e
));
var
uri3
=
URI
.
parse
(
value
.
toString
(
true
));
var
uri2
=
URI
.
parse
(
value
.
toString
(
tru
e
));
var
uri3
=
URI
.
parse
(
value
.
toString
());
assert
.
equal
(
uri2
.
authority
,
uri3
.
authority
);
assert
.
equal
(
uri2
.
path
,
uri3
.
path
);
assert
.
equal
(
uri2
.
query
,
uri3
.
query
);
...
...
@@ -353,7 +353,7 @@ suite('URI', () => {
let
uri
=
URI
.
parse
(
'
http://go.microsoft.com/fwlink/?LinkId=518008
'
);
assert
.
equal
(
uri
.
query
,
'
LinkId=518008
'
);
assert
.
equal
(
uri
.
toString
(
fals
e
),
'
http://go.microsoft.com/fwlink/?LinkId=518008
'
);
assert
.
equal
(
uri
.
toString
(
tru
e
),
'
http://go.microsoft.com/fwlink/?LinkId=518008
'
);
assert
.
equal
(
uri
.
toString
(),
'
http://go.microsoft.com/fwlink/?LinkId%3D518008
'
);
let
uri2
=
URI
.
parse
(
uri
.
toString
());
...
...
@@ -362,7 +362,7 @@ suite('URI', () => {
uri
=
URI
.
parse
(
'
http://go.microsoft.com/fwlink/?LinkId=518008&foö&ké¥=üü
'
);
assert
.
equal
(
uri
.
query
,
'
LinkId=518008&foö&ké¥=üü
'
);
assert
.
equal
(
uri
.
toString
(
fals
e
),
'
http://go.microsoft.com/fwlink/?LinkId=518008&foö&ké¥=üü
'
);
assert
.
equal
(
uri
.
toString
(
tru
e
),
'
http://go.microsoft.com/fwlink/?LinkId=518008&foö&ké¥=üü
'
);
assert
.
equal
(
uri
.
toString
(),
'
http://go.microsoft.com/fwlink/?LinkId%3D518008%26fo%C3%B6%26k%C3%A9%C2%A5%3D%C3%BC%C3%BC
'
);
uri2
=
URI
.
parse
(
uri
.
toString
());
...
...
src/vs/vscode.d.ts
浏览文件 @
65cb3397
...
...
@@ -928,21 +928,24 @@ declare namespace vscode {
fragment
:
string
;
/**
* The string representing the corresponding file system path of this U
RI
.
* The string representing the corresponding file system path of this U
ri
.
*
* Will handle UNC paths and normalize windows drive letters to lower-case. Also
* uses the platform specific path separator. Will *not* validate the path for
* invalid characters and semantics. Will *not* look at the scheme of this U
RI
.
* invalid characters and semantics. Will *not* look at the scheme of this U
ri
.
*/
fsPath
:
string
;
/**
* Returns a canonical representation of this URI. The representation and normalization
* of a URI depends on the scheme.
* 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
* [Uri.parse](#Uri.parse).
*
* @returns A string that is the encoded version of this Uri.
* @param skipEncoding Do not percentage-encode the result, defaults to `false`. Note that
* the `#` and `?` characters occuring in the path will always be encoded.
* @returns A string representation of this Uri.
*/
toString
():
string
;
toString
(
skipEncoding
?:
boolean
):
string
;
/**
* Returns a JSON representation of this Uri.
...
...
src/vs/workbench/services/editor/browser/editorService.ts
浏览文件 @
65cb3397
...
...
@@ -136,7 +136,7 @@ export class WorkbenchEditorService implements IWorkbenchEditorService {
if
(
resourceInput
.
resource
instanceof
URI
)
{
let
schema
=
resourceInput
.
resource
.
scheme
;
if
(
schema
===
network
.
Schemas
.
http
||
schema
===
network
.
Schemas
.
https
)
{
window
.
open
(
resourceInput
.
resource
.
toString
(
fals
e
));
window
.
open
(
resourceInput
.
resource
.
toString
(
tru
e
));
return
TPromise
.
as
<
IEditor
>
(
null
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录