Skip to content

Commit

Permalink
Added check to avoid the incorrect mention of renaming for subimages …
Browse files Browse the repository at this point in the history
…that differ in subimage name only.
  • Loading branch information
KevinNamink committed Mar 28, 2022
1 parent 221b47e commit 58d737e
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion scripts/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -1003,8 +1004,16 @@ function imgPrev(infile, mode, gen, sanitized, compare, index,
+ '>'
+ '<img src="images/eye.png"> '
+ '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 + '</div>';
}
Expand Down

0 comments on commit 58d737e

Please sign in to comment.