Fix the broken regular expression in the decode helper in the getPdfFilenameFromUrl function (issue 20664)

This will ignore filenames that become effectively empty, i.e. ones that are only ".pdf" and nothing more.

*Please note:* While this passes all existing unit-tests, I don't know if this is necessarily the "correct" solution here.
This commit is contained in:
Jonas Jenwald 2026-02-27 15:19:43 +01:00
parent 218a687a3b
commit e3a7c0779d

View File

@ -377,10 +377,9 @@ function getPdfFilenameFromUrl(url, defaultFilename = "document.pdf") {
let decoded = decodeURIComponent(name);
if (decoded.includes("/")) {
decoded = stripPath(decoded);
if (decoded.test(/^\.pdf$/i)) {
return decoded;
if (/^\.pdf$/i.test(decoded)) {
return name;
}
return name;
}
return decoded;
} catch {