Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
1f6815a8
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,发现更多精彩内容 >>
提交
1f6815a8
编写于
9月 14, 2016
作者:
M
Martin Aeschlimann
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[html] get all link tests to run
上级
8d7504f7
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
15 addition
and
16 deletion
+15
-16
extensions/html/server/src/service/services/htmlLinks.ts
extensions/html/server/src/service/services/htmlLinks.ts
+9
-10
extensions/html/server/src/service/test/links.test.ts
extensions/html/server/src/service/test/links.test.ts
+6
-6
未找到文件。
extensions/html/server/src/service/services/htmlLinks.ts
浏览文件 @
1f6815a8
...
...
@@ -18,7 +18,7 @@ function _stripQuotes(url: string): string {
.
replace
(
/^"
([^
"
]
+
)
"$/
,(
substr
,
match1
)
=>
match1
);
}
export
function
_getWorkspaceUrl
(
modelAbsoluteUri
:
Uri
,
rootAbsoluteUrl
Str
:
string
,
tokenContent
:
string
):
string
{
export
function
_getWorkspaceUrl
(
modelAbsoluteUri
:
Uri
,
rootAbsoluteUrl
:
Uri
,
tokenContent
:
string
):
string
{
tokenContent
=
_stripQuotes
(
tokenContent
);
if
(
/^
\s
*javascript
\:
/i
.
test
(
tokenContent
)
||
/^
\s
*
\#
/i
.
test
(
tokenContent
))
{
...
...
@@ -47,9 +47,10 @@ export function _getWorkspaceUrl(modelAbsoluteUri: Uri, rootAbsoluteUrlStr: stri
alternativeResultPath
=
paths
.
join
(
modelPath
,
tokenContent
);
alternativeResultPath
=
alternativeResultPath
.
replace
(
/^
(\/\.\.)
+/
,
''
);
}
let
potentialResult
=
modelAbsoluteUri
.
with
({
path
:
alternativeResultPath
}).
toString
();
let
potentialResult
=
modelAbsoluteUri
.
with
({
path
:
alternativeResultPath
}).
toString
(
true
);
if
(
rootAbsoluteUrlStr
&&
strings
.
startsWith
(
modelAbsoluteUri
.
toString
(),
rootAbsoluteUrlStr
))
{
let
rootAbsoluteUrlStr
=
rootAbsoluteUrl
&&
rootAbsoluteUrl
.
toString
(
true
);
if
(
rootAbsoluteUrlStr
&&
strings
.
startsWith
(
modelAbsoluteUri
.
toString
(
true
),
rootAbsoluteUrlStr
))
{
// The `rootAbsoluteUrl` is set and matches our current model
// We need to ensure that this `potentialResult` does not escape `rootAbsoluteUrl`
...
...
@@ -63,7 +64,7 @@ export function _getWorkspaceUrl(modelAbsoluteUri: Uri, rootAbsoluteUrlStr: stri
return
potentialResult
;
}
function
createLink
(
document
:
TextDocument
,
rootAbsoluteUrl
:
string
,
tokenContent
:
string
,
startOffset
:
number
,
endOffset
:
number
):
DocumentLink
{
function
createLink
(
document
:
TextDocument
,
rootAbsoluteUrl
:
Uri
,
tokenContent
:
string
,
startOffset
:
number
,
endOffset
:
number
):
DocumentLink
{
let
documentUri
=
Uri
.
parse
(
document
.
uri
);
let
workspaceUrl
=
_getWorkspaceUrl
(
documentUri
,
rootAbsoluteUrl
,
tokenContent
);
if
(
!
workspaceUrl
)
{
...
...
@@ -78,15 +79,13 @@ function createLink(document: TextDocument, rootAbsoluteUrl: string, tokenConten
export
function
provideLinks
(
document
:
TextDocument
,
workspacePath
:
string
):
DocumentLink
[]
{
let
newLinks
:
DocumentLink
[]
=
[];
let
rootAbsoluteUrl
:
string
=
null
;
let
rootAbsoluteUrl
:
Uri
=
null
;
if
(
workspacePath
)
{
// The workspace can be null in the no folder opened case
let
strRootAbsoluteUrl
=
workspacePath
;
if
(
strRootAbsoluteUrl
.
charAt
(
strRootAbsoluteUrl
.
length
-
1
)
===
'
/
'
)
{
rootAbsoluteUrl
=
strRootAbsoluteUrl
;
}
else
{
rootAbsoluteUrl
=
strRootAbsoluteUrl
+
'
/
'
;
if
(
workspacePath
.
charAt
(
workspacePath
.
length
-
1
)
!==
'
/
'
)
{
workspacePath
=
workspacePath
+
'
/
'
;
}
rootAbsoluteUrl
=
Uri
.
parse
(
workspacePath
);
}
let
scanner
=
createScanner
(
document
.
getText
(),
0
);
...
...
extensions/html/server/src/service/test/links.test.ts
浏览文件 @
1f6815a8
...
...
@@ -14,7 +14,7 @@ suite('HTML Link Detection', () => {
function
testLinkCreation
(
modelUrl
:
string
,
rootUrl
:
string
,
tokenContent
:
string
,
expected
:
string
):
void
{
var
_modelUrl
=
Uri
.
parse
(
modelUrl
);
var
actual
=
htmlLinks
.
_getWorkspaceUrl
(
_modelUrl
,
rootUrl
,
tokenContent
);
var
actual
=
htmlLinks
.
_getWorkspaceUrl
(
_modelUrl
,
Uri
.
parse
(
rootUrl
)
,
tokenContent
);
assert
.
equal
(
actual
,
expected
);
}
...
...
@@ -44,7 +44,7 @@ suite('HTML Link Detection', () => {
testLinkCreation
(
'
file:///C:/Alex/src/path/to/file.txt
'
,
null
,
'
http://www.microsoft.com/
'
,
'
http://www.microsoft.com/
'
);
testLinkCreation
(
'
file:///C:/Alex/src/path/to/file.txt
'
,
null
,
'
https://www.microsoft.com/
'
,
'
https://www.microsoft.com/
'
);
testLinkCreation
(
'
file:///C:/Alex/src/path/to/file.txt
'
,
null
,
'
//www.microsoft.com/
'
,
'
http://www.microsoft.com/
'
);
//testLinkCreation('file:///C:/Alex/src/path/to/file.txt', null, 'a.js', 'file:///C
:/Alex/src/path/to/a.js');
testLinkCreation
(
'
file:///C:/Alex/src/path/to/file.txt
'
,
null
,
'
a.js
'
,
'
file:///c
:/Alex/src/path/to/a.js
'
);
testLinkCreation
(
'
file:///C:/Alex/src/path/to/file.txt
'
,
null
,
'
/a.js
'
,
'
file:///a.js
'
);
testLinkCreation
(
'
file:///C:/Alex/src/path/to/file.txt
'
,
'
file:///C:/Alex/src/
'
,
'
javascript:void;
'
,
null
);
...
...
@@ -55,17 +55,17 @@ suite('HTML Link Detection', () => {
testLinkCreation
(
'
file:///C:/Alex/src/path/to/file.txt
'
,
'
file:///C:/Alex/src/
'
,
'
https://www.microsoft.com/
'
,
'
https://www.microsoft.com/
'
);
testLinkCreation
(
'
file:///C:/Alex/src/path/to/file.txt
'
,
'
file:///C:/Alex/src/
'
,
'
https://www.microsoft.com/?q=1#h
'
,
'
https://www.microsoft.com/?q=1#h
'
);
testLinkCreation
(
'
file:///C:/Alex/src/path/to/file.txt
'
,
'
file:///C:/Alex/src/
'
,
'
//www.microsoft.com/
'
,
'
http://www.microsoft.com/
'
);
//testLinkCreation('file:///C:/Alex/src/path/to/file.txt', 'file:///C:/Alex/src/', 'a.js', 'file:///C
:/Alex/src/path/to/a.js');
//testLinkCreation('file:///C:/Alex/src/path/to/file.txt', 'file:///C:/Alex/src/', '/a.js', 'file:///C
:/Alex/src/a.js');
testLinkCreation
(
'
file:///C:/Alex/src/path/to/file.txt
'
,
'
file:///C:/Alex/src/
'
,
'
a.js
'
,
'
file:///c
:/Alex/src/path/to/a.js
'
);
testLinkCreation
(
'
file:///C:/Alex/src/path/to/file.txt
'
,
'
file:///C:/Alex/src/
'
,
'
/a.js
'
,
'
file:///c
:/Alex/src/a.js
'
);
testLinkCreation
(
'
https://www.test.com/path/to/file.txt
'
,
null
,
'
file:///C:
\\
Alex
\\
src
\\
path
\\
to
\\
file.txt
'
,
'
file:///C:
\\
Alex
\\
src
\\
path
\\
to
\\
file.txt
'
);
testLinkCreation
(
'
https://www.test.com/path/to/file.txt
'
,
null
,
'
//www.microsoft.com/
'
,
'
https://www.microsoft.com/
'
);
testLinkCreation
(
'
https://www.test.com/path/to/file.txt
'
,
'
https://www.test.com
'
,
'
//www.microsoft.com/
'
,
'
https://www.microsoft.com/
'
);
// invalid uris don't throw
testLinkCreation
(
'
https://www.test.com/path/to/file.txt
'
,
'
https://www.test.com
'
,
'
%
'
,
'
https://www.test.com/path/to/%
25
'
);
testLinkCreation
(
'
https://www.test.com/path/to/file.txt
'
,
'
https://www.test.com
'
,
'
%
'
,
'
https://www.test.com/path/to/%
'
);
// Bug #18314: Ctrl + Click does not open existing file if folder's name starts with 'c' character
//
testLinkCreation('file:///c:/Alex/working_dir/18314-link-detection/test.html', 'file:///c:/Alex/working_dir/18314-link-detection/', '/class/class.js', 'file:///c:/Alex/working_dir/18314-link-detection/class/class.js');
testLinkCreation
(
'
file:///c:/Alex/working_dir/18314-link-detection/test.html
'
,
'
file:///c:/Alex/working_dir/18314-link-detection/
'
,
'
/class/class.js
'
,
'
file:///c:/Alex/working_dir/18314-link-detection/class/class.js
'
);
});
});
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录