From 041b2dfcc13ea4d089d85eebdc319cba2278e11b Mon Sep 17 00:00:00 2001 From: Cornelicorn <40914430+Cornelicorn@users.noreply.github.com> Date: Sun, 21 Jun 2020 14:48:13 +0200 Subject: [PATCH] Fix tag-adding bugs of the importer (#427) --- docs-importer/main.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/docs-importer/main.js b/docs-importer/main.js index 71c4ac40..20600f5c 100644 --- a/docs-importer/main.js +++ b/docs-importer/main.js @@ -393,6 +393,12 @@ const importFile = (file, remove, resolve) => { // Intersect tags from filename with existing tags on server let foundtags = []; for (let j of taglist) { + // If the tag is last in the filename it could include a file extension and would not be recognized + if (j.includes('.') && !tagsarray.hasOwnProperty(j) && !foundtags.includes(tagsarray[j])) { + while (j.includes('.') && !tagsarray.hasOwnProperty(j)) { + j = j.replace(/\.[^.]*$/,''); + } + } if (tagsarray.hasOwnProperty(j) && !foundtags.includes(tagsarray[j])) { foundtags.push(tagsarray[j]); filename = filename.split('#'+j).join(''); @@ -413,7 +419,8 @@ const importFile = (file, remove, resolve) => { else { data = { title: prefs.importer.addtags ? filename : file.replace(/^.*[\\\/]/, '').substring(0, 100), - language: prefs.importer.lang || 'eng' + language: prefs.importer.lang || 'eng', + tags: prefs.importer.tag === '' ? undefined : prefs.importer.tag } } // Create document