浏览代码

Attachment, path was wrong if the file hasn't a extension

Martin Filser 2 年之前
父节点
当前提交
25443926d3
共有 1 个文件被更改,包括 6 次插入1 次删除
  1. 6 1
      models/attachments.js

+ 6 - 1
models/attachments.js

@@ -59,7 +59,12 @@ Attachments = new FilesCollection({
       delete opts.meta.fileId;
     } else if (opts?.file?.name) {
       // Server
-      filenameWithoutExtension = opts.file.name.replace(new RegExp(opts.file.extensionWithDot + "$"), "")
+      if (opts.file.extension) {
+        filenameWithoutExtension = opts.file.name.replace(new RegExp(opts.file.extensionWithDot + "$"), "")
+      } else {
+        // file has no extension, so don't replace anything, otherwise the last character is removed (because extensionWithDot = '.')
+        filenameWithoutExtension = opts.file.name;
+      }
       fileId = opts.fileId;
     }
     else {