Skip to content

Commit

Permalink
Merge pull request #117 from lonekorean/uri-malformed
Browse files Browse the repository at this point in the history
Catch URIError
  • Loading branch information
lonekorean authored Mar 1, 2024
2 parents e71fb12 + 47df034 commit 1cbe2ba
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/shared.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
function getFilenameFromUrl(url) {
return decodeURIComponent(url.split('/').slice(-1)[0]);
let filename = url.split('/').slice(-1)[0];
try {
filename = decodeURIComponent(filename)
} catch (ex) {
// filename could not be decoded because of improper encoding with %
// leave filename as-is and continue
}
return filename;
}

exports.getFilenameFromUrl = getFilenameFromUrl;

0 comments on commit 1cbe2ba

Please sign in to comment.