1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-20 15:18:08 +02:00

Use a limit, in more places, when splitting strings

This should be a *tiny* bit more efficient, since it avoids parsing substrings that we don't care about.

*Please note:* I cannot find an ESLint rule to enforce this automatically.
This commit is contained in:
Jonas Jenwald 2024-02-02 13:02:31 +01:00
parent af4d2fa53c
commit 363dce6744
6 changed files with 8 additions and 8 deletions

View file

@ -17,7 +17,7 @@ import { getPdfFilenameFromUrl } from "pdfjs-lib";
async function docProperties(pdfDocument) {
const url = "",
baseUrl = url.split("#")[0];
baseUrl = url.split("#", 1)[0];
// eslint-disable-next-line prefer-const
let { info, metadata, contentDispositionFilename, contentLength } =
await pdfDocument.getMetadata();

View file

@ -385,7 +385,7 @@ class PDFHistory {
let newUrl;
if (this._updateUrl && destination?.hash) {
const baseUrl = document.location.href.split("#")[0];
const baseUrl = document.location.href.split("#", 1)[0];
// Prevent errors in Firefox.
if (!baseUrl.startsWith("file://")) {
newUrl = `${baseUrl}#${destination.hash}`;