forked from SuperMap/iClient-JavaScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUtil.js
More file actions
25 lines (23 loc) · 924 Bytes
/
Util.js
File metadata and controls
25 lines (23 loc) · 924 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/* Copyright© 2000 - 2018 SuperMap Software Co.Ltd. All rights reserved.
* This program are made available under the terms of the Apache License, Version 2.0
* which accompanies this distribution and is available at http://www.apache.org/licenses/LICENSE-2.0.html.*/
import {FileTypes} from '../CommonTypes';
export let widgetsUtil = {
/**
* 获取上传文件类型
* @param fileName
*/
getFileType(fileName) {
let regCSV = /^.*\.(?:csv)$/i;
let regExcel = /^.*\.(?:xls|xlsx)$/i; //文件名可以带空格
let regGeojson = /^.*\.(?:geojson|json)$/i;
if (regExcel.test(fileName)) { //校验不通过
return FileTypes.EXCEL;
} else if (regCSV.test(fileName)) {
return FileTypes.CSV;
} else if (regGeojson.test(fileName)) {
return FileTypes.GEOJSON;
}
return null;
}
};