[api-minor] Remove the unused onlyStripPath option from the getFilenameFromUrl helper function

This commit is contained in:
Jonas Jenwald 2024-05-03 08:29:41 +02:00
parent 2b69fb76ac
commit a790f2df5d
2 changed files with 2 additions and 12 deletions

View file

@ -803,13 +803,10 @@ function isPdfFile(filename) {
/** /**
* Gets the filename from a given URL. * Gets the filename from a given URL.
* @param {string} url * @param {string} url
* @param {boolean} [onlyStripPath]
* @returns {string} * @returns {string}
*/ */
function getFilenameFromUrl(url, onlyStripPath = false) { function getFilenameFromUrl(url) {
if (!onlyStripPath) { [url] = url.split(/[#?]/, 1);
[url] = url.split(/[#?]/, 1);
}
return url.substring(url.lastIndexOf("/") + 1); return url.substring(url.lastIndexOf("/") + 1);
} }

View file

@ -189,13 +189,6 @@ describe("display_utils", function () {
const url = "https://server.org/filename.pdf?foo=bar"; const url = "https://server.org/filename.pdf?foo=bar";
expect(getFilenameFromUrl(url)).toEqual("filename.pdf"); expect(getFilenameFromUrl(url)).toEqual("filename.pdf");
}); });
it("should get the filename from a relative URL, keeping the anchor", function () {
const url = "../../part1#part2.pdf";
expect(getFilenameFromUrl(url, /* onlyStripPath = */ true)).toEqual(
"part1#part2.pdf"
);
});
}); });
describe("getPdfFilenameFromUrl", function () { describe("getPdfFilenameFromUrl", function () {