Liyuan Li 5 years ago
parent
commit
ce7c87f180
3 changed files with 7 additions and 5 deletions
  1. 1 0
      CHANGELOG.md
  2. 1 0
      README.md
  3. 5 5
      src/ts/upload/index.ts

+ 1 - 0
CHANGELOG.md

@@ -68,6 +68,7 @@
 
 ### v3.3.4 / 2020-07-xx
 
+* [536](https://github.com/Vanessa219/vditor/issues/536) 文件上传检查后缀忽略大小写 `改进功能`
 * [537](https://github.com/Vanessa219/vditor/issues/537) 添加 destroy 方法 `引入特新`
 * [532](https://github.com/Vanessa219/vditor/issues/532) 中文输入过程中不应记录 UndoStack `修复缺陷`
 * [519](https://github.com/Vanessa219/vditor/issues/519) 扩展 markdown 主题 `改进功能`

+ 1 - 0
README.md

@@ -378,6 +378,7 @@ xhr.send(JSON.stringify({url: src})); // src is the address of the image outside
 | setPreviewMode(mode: "both" \| "editor") | Set preview mode |
 | setTheme(theme: "dark" | "classic", contentTheme?: string, codeTheme?: string, contentThemePath?: string) | Set theme |
 | getCurrentMode(): string | Get the editor's current editing mode |
+| destroy() | Destroy the vditor |
 
 #### static methods
 

+ 5 - 5
src/ts/upload/index.ts

@@ -42,18 +42,18 @@ const validateFile = (vditor: IVditor, files: File[]) => {
         const filename = vditor.options.upload.filename(file.name.substr(0, lastIndex)) + fileExt;
 
         if (vditor.options.upload.accept) {
-            let isAccept = false;
-            vditor.options.upload.accept.split(",").forEach((item) => {
+            const isAccept = vditor.options.upload.accept.split(",").some((item) => {
                 const type = item.trim();
                 if (type.indexOf(".") === 0) {
-                    if (fileExt === type) {
-                        isAccept = true;
+                    if (fileExt.toLowerCase() === type.toLowerCase()) {
+                        return true;
                     }
                 } else {
                     if (file.type.split("/")[0] === type.split("/")[0]) {
-                        isAccept = true;
+                        return true;
                     }
                 }
+                return false;
             });
 
             if (!isAccept) {