Merge pull request #20757 from Snuffleupagus/getPdfFilenameFromUrl-fix-decode-regex

Fix the broken regular expression in the `decode` helper in the `getPdfFilenameFromUrl` function (issue 20664)
This commit is contained in:
Jonas Jenwald 2026-02-27 23:14:18 +01:00 committed by GitHub
commit 86573cc995
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

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 {