mirror of
https://github.com/ant-design/ant-design.git
synced 2025-08-05 23:46:28 +08:00
fix(upload): should work correctly when url of file is null (#30215)
* fix(upload): should work correctly when url of file is null * fix: lint
This commit is contained in:
parent
7975c33f50
commit
1f1aa86441
@ -6,7 +6,7 @@ import produce from 'immer';
|
||||
import { cloneDeep } from 'lodash';
|
||||
import Upload from '..';
|
||||
import Form from '../../form';
|
||||
import { getFileItem, removeFileItem } from '../utils';
|
||||
import { getFileItem, removeFileItem, isImageUrl } from '../utils';
|
||||
import { setup, teardown } from './mock';
|
||||
import { resetWarned } from '../../_util/devWarning';
|
||||
import mountTest from '../../../tests/shared/mountTest';
|
||||
@ -367,6 +367,13 @@ describe('Upload', () => {
|
||||
const targetItem = removeFileItem(file, fileList);
|
||||
expect(targetItem).toBe(null);
|
||||
});
|
||||
|
||||
it('isImageUrl should work correctly when file.url is null', () => {
|
||||
const file = {
|
||||
url: null,
|
||||
};
|
||||
expect(isImageUrl(file)).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
it('should support linkProps as object', () => {
|
||||
|
@ -54,7 +54,7 @@ export const isImageUrl = (file: UploadFile): boolean => {
|
||||
if (file.type && !file.thumbUrl) {
|
||||
return isImageFileType(file.type);
|
||||
}
|
||||
const url: string = (file.thumbUrl || file.url) as string;
|
||||
const url: string = (file.thumbUrl || file.url || '') as string;
|
||||
const extension = extname(url);
|
||||
if (
|
||||
/^data:image\//.test(url) ||
|
||||
|
Loading…
Reference in New Issue
Block a user