Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
aa532911
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
aa532911
编写于
8月 30, 2019
作者:
J
Jan Beckmann
提交者:
Paul Slaughter
8月 30, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
URL-encode file links in find file
Fixes
https://gitlab.com/gitlab-org/gitlab-ce/issues/62055
上级
92855f2c
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
83 addition
and
1 deletion
+83
-1
app/assets/javascripts/project_find_file.js
app/assets/javascripts/project_find_file.js
+1
-1
changelogs/unreleased/62055-find-file-links-encoding.yml
changelogs/unreleased/62055-find-file-links-encoding.yml
+5
-0
spec/frontend/project_find_file_spec.js
spec/frontend/project_find_file_spec.js
+77
-0
未找到文件。
app/assets/javascripts/project_find_file.js
浏览文件 @
aa532911
...
...
@@ -113,7 +113,7 @@ export default class ProjectFindFile {
if
(
searchText
)
{
matches
=
fuzzaldrinPlus
.
match
(
filePath
,
searchText
);
}
blobItemUrl
=
this
.
options
.
blobUrlTemplate
+
'
/
'
+
filePath
;
blobItemUrl
=
this
.
options
.
blobUrlTemplate
+
'
/
'
+
encodeURIComponent
(
filePath
)
;
html
=
ProjectFindFile
.
makeHtml
(
filePath
,
matches
,
blobItemUrl
);
results
.
push
(
this
.
element
.
find
(
'
.tree-table > tbody
'
).
append
(
html
));
}
...
...
changelogs/unreleased/62055-find-file-links-encoding.yml
0 → 100644
浏览文件 @
aa532911
---
title
:
Fix encoding of special characters in "Find File"
merge_request
:
31311
author
:
Jan Beckmann
type
:
fixed
spec/frontend/project_find_file_spec.js
0 → 100644
浏览文件 @
aa532911
import
MockAdapter
from
'
axios-mock-adapter
'
;
import
$
from
'
jquery
'
;
import
ProjectFindFile
from
'
~/project_find_file
'
;
import
axios
from
'
~/lib/utils/axios_utils
'
;
import
{
TEST_HOST
}
from
'
helpers/test_constants
'
;
const
BLOB_URL_TEMPLATE
=
`
${
TEST_HOST
}
/namespace/project/blob/master`
;
const
FILE_FIND_URL
=
`
${
TEST_HOST
}
/namespace/project/files/master?format=json`
;
const
FIND_TREE_URL
=
`
${
TEST_HOST
}
/namespace/project/tree/master`
;
const
TEMPLATE
=
`<div class="file-finder-holder tree-holder js-file-finder" data-blob-url-template="
${
BLOB_URL_TEMPLATE
}
" data-file-find-url="
${
FILE_FIND_URL
}
" data-find-tree-url="
${
FIND_TREE_URL
}
">
<input class="file-finder-input" id="file_find" />
<div class="tree-content-holder">
<div class="table-holder">
<table class="files-slider tree-table">
<tbody />
</table>
</div>
</div>
</div>`
;
describe
(
'
ProjectFindFile
'
,
()
=>
{
let
element
;
let
mock
;
const
getProjectFindFileInstance
=
()
=>
new
ProjectFindFile
(
element
,
{
url
:
FILE_FIND_URL
,
treeUrl
:
FIND_TREE_URL
,
blobUrlTemplate
:
BLOB_URL_TEMPLATE
,
});
const
findFiles
=
()
=>
element
.
find
(
'
.tree-table tr
'
)
.
toArray
()
.
map
(
el
=>
({
text
:
el
.
textContent
,
href
:
el
.
querySelector
(
'
a
'
).
href
,
}));
beforeEach
(()
=>
{
// Create a mock adapter for stubbing axios API requests
mock
=
new
MockAdapter
(
axios
);
element
=
$
(
TEMPLATE
);
});
afterEach
(()
=>
{
// Reset the mock adapter
mock
.
restore
();
});
it
(
'
loads and renders elements from remote server
'
,
done
=>
{
const
files
=
[
'
fileA.txt
'
,
'
fileB.txt
'
,
'
fi#leC.txt
'
,
'
folderA/fileD.txt
'
,
'
folder#B/fileE.txt
'
,
'
folde?rC/fil#F.txt
'
,
];
mock
.
onGet
(
FILE_FIND_URL
).
replyOnce
(
200
,
files
);
getProjectFindFileInstance
();
// This triggers a load / axios call + subsequent render in the constructor
setImmediate
(()
=>
{
expect
(
findFiles
()).
toEqual
(
files
.
map
(
text
=>
({
text
,
href
:
`
${
BLOB_URL_TEMPLATE
}
/
${
encodeURIComponent
(
text
)}
`
,
})),
);
done
();
});
});
});
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录