From 58d737e19c08e5c73dcdef2db100ba7e5225903c Mon Sep 17 00:00:00 2001 From: Kevin Namink Date: Mon, 28 Mar 2022 16:17:51 +0200 Subject: [PATCH] Added check to avoid the incorrect mention of renaming for subimages that differ in subimage name only. --- scripts/common.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/scripts/common.js b/scripts/common.js index 2fcbf7fa..c3cd976e 100644 --- a/scripts/common.js +++ b/scripts/common.js @@ -947,6 +947,7 @@ function imgPrev(infile, mode, gen, sanitized, compare, index, dir, referer, data) { var file = unescape(infile); var tip, html, link, onClick = ""; + var regexpRes; if (mode == 0 && gen == 1) { try @@ -1003,8 +1004,16 @@ function imgPrev(infile, mode, gen, sanitized, compare, index, + '>' + ' ' + 'Click to generate preview'; + + // Check if the (base)names of the sanitized and original name + // are the same, otherwise mention that it will rename the file. if ( infile != sanitized ) { - html = html + ' (the file will be renamed)'; + regexpRes = /^(.+)\ \(.+\)$/g.exec(file); + if (regexpRes && sanitized.startsWith(regexpRes[1])) { + // It is not a subimage or the basename is the same. + } else { + html = html + ' (the file will be renamed)'; + } } html = html + ''; }