mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-20 15:18:08 +02:00
Simplify the getFilenameFromUrl
helper function
This commit is contained in:
parent
0ba242ea4a
commit
f3e0f86641
1 changed files with 2 additions and 5 deletions
|
@ -338,13 +338,10 @@ function isPdfFile(filename) {
|
|||
* @returns {string}
|
||||
*/
|
||||
function getFilenameFromUrl(url, onlyStripPath = false) {
|
||||
let end = url.length;
|
||||
if (!onlyStripPath) {
|
||||
const anchor = url.indexOf("#");
|
||||
const query = url.indexOf("?");
|
||||
end = Math.min(anchor > 0 ? anchor : end, query > 0 ? query : end);
|
||||
[url] = url.split(/[#?]/, 1);
|
||||
}
|
||||
return url.substring(url.lastIndexOf("/", end) + 1, end);
|
||||
return url.substring(url.lastIndexOf("/") + 1);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue