Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
wanjj_1210
ant-design
提交
3b00cf89
A
ant-design
项目概览
wanjj_1210
/
ant-design
与 Fork 源项目一致
从无法访问的项目Fork
通知
10
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
A
ant-design
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
3b00cf89
编写于
4月 17, 2018
作者:
A
afc163
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix image when file.url has query or hash
close #10102
上级
7e829576
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
125 addition
and
3 deletion
+125
-3
components/upload/UploadList.tsx
components/upload/UploadList.tsx
+5
-3
components/upload/__tests__/__snapshots__/uploadlist.test.js.snap
...ts/upload/__tests__/__snapshots__/uploadlist.test.js.snap
+102
-0
components/upload/__tests__/uploadlist.test.js
components/upload/__tests__/uploadlist.test.js
+18
-0
未找到文件。
components/upload/UploadList.tsx
浏览文件 @
3b00cf89
...
...
@@ -19,15 +19,17 @@ const extname = (url: string) => {
}
const
temp
=
url
.
split
(
'
/
'
);
const
filename
=
temp
[
temp
.
length
-
1
];
return
(
/
\.[^
.
/\\]
*$/
.
exec
(
filename
)
||
[
''
])[
0
];
const
filenameWithoutSuffix
=
filename
.
split
(
/
\#
|
\?
/
)[
0
];
return
(
/
\.[^
.
/\\]
*$/
.
exec
(
filenameWithoutSuffix
)
||
[
''
])[
0
];
};
const
isImageUrl
=
(
url
:
string
):
boolean
=>
{
if
(
/^data:image
\/
/
.
test
(
url
)
||
/
\.(
webp|svg|png|gif|jpg|jpeg
)
$/
.
test
(
url
))
{
const
extension
=
extname
(
url
);
if
(
/^data:image
\/
/
.
test
(
url
)
||
/
(
webp|svg|png|gif|jpg|jpeg
)
$/
.
test
(
extension
))
{
return
true
;
}
else
if
(
/^data:/
.
test
(
url
))
{
// other file types of base64
return
false
;
}
else
if
(
ext
name
(
url
)
)
{
// other file types which have extension
}
else
if
(
ext
ension
)
{
// other file types which have extension
return
false
;
}
return
true
;
...
...
components/upload/__tests__/__snapshots__/uploadlist.test.js.snap
浏览文件 @
3b00cf89
...
...
@@ -448,6 +448,108 @@ exports[`Upload List should non-image format file preview 1`] = `
title="Remove file"
/>
</div>
<div
class="ant-upload-list-item ant-upload-list-item-done"
>
<div
class="ant-upload-list-item-info"
>
<span>
<a
class="ant-upload-list-item-thumbnail"
href="https://cdn.xxx.com/xx.xx/aaa.png?query=123"
rel="noopener noreferrer"
target="_blank"
>
<img
alt="image"
src="https://cdn.xxx.com/xx.xx/aaa.png?query=123"
/>
</a>
<a
class="ant-upload-list-item-name"
href="https://cdn.xxx.com/xx.xx/aaa.png?query=123"
rel="noopener noreferrer"
target="_blank"
title="image"
>
image
</a>
</span>
</div>
<i
class="anticon anticon-cross"
title="Remove file"
/>
</div>
<div
class="ant-upload-list-item ant-upload-list-item-done"
>
<div
class="ant-upload-list-item-info"
>
<span>
<a
class="ant-upload-list-item-thumbnail"
href="https://cdn.xxx.com/xx.xx/aaa.png#anchor"
rel="noopener noreferrer"
target="_blank"
>
<img
alt="image"
src="https://cdn.xxx.com/xx.xx/aaa.png#anchor"
/>
</a>
<a
class="ant-upload-list-item-name"
href="https://cdn.xxx.com/xx.xx/aaa.png#anchor"
rel="noopener noreferrer"
target="_blank"
title="image"
>
image
</a>
</span>
</div>
<i
class="anticon anticon-cross"
title="Remove file"
/>
</div>
<div
class="ant-upload-list-item ant-upload-list-item-done"
>
<div
class="ant-upload-list-item-info"
>
<span>
<a
class="ant-upload-list-item-thumbnail"
href="https://cdn.xxx.com/xx.xx/aaa.png?query=some.query.with.dot"
rel="noopener noreferrer"
target="_blank"
>
<img
alt="image"
src="https://cdn.xxx.com/xx.xx/aaa.png?query=some.query.with.dot"
/>
</a>
<a
class="ant-upload-list-item-name"
href="https://cdn.xxx.com/xx.xx/aaa.png?query=some.query.with.dot"
rel="noopener noreferrer"
target="_blank"
title="image"
>
image
</a>
</span>
</div>
<i
class="anticon anticon-cross"
title="Remove file"
/>
</div>
</div>
</span>
`;
components/upload/__tests__/uploadlist.test.js
浏览文件 @
3b00cf89
...
...
@@ -303,6 +303,24 @@ describe('Upload List', () => {
url
:
'
https://cdn.xxx.com/xx.xx/aaa.png
'
,
thumbUrl
:
'
data:image/png;base64,UEsDBAoAAAAAADYZYkwAAAAAAAAAAAAAAAAdAAk
'
,
},
{
name
:
'
image
'
,
status
:
'
done
'
,
uid
:
-
9
,
url
:
'
https://cdn.xxx.com/xx.xx/aaa.png?query=123
'
,
},
{
name
:
'
image
'
,
status
:
'
done
'
,
uid
:
-
10
,
url
:
'
https://cdn.xxx.com/xx.xx/aaa.png#anchor
'
,
},
{
name
:
'
image
'
,
status
:
'
done
'
,
uid
:
-
11
,
url
:
'
https://cdn.xxx.com/xx.xx/aaa.png?query=some.query.with.dot
'
,
},
];
const
wrapper
=
mount
(
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录