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

Move the escapeString helper function into the worker-thread

Given that this helper function is only used on the worker-thread, there's no reason to duplicate it in both of the `pdf.js` and `pdf.worker.js` files.
This commit is contained in:
Jonas Jenwald 2022-11-16 12:18:13 +01:00
parent e5859e145d
commit 9adc7859c8
6 changed files with 31 additions and 27 deletions

View file

@ -17,6 +17,7 @@ import { Dict, Ref } from "../../src/core/primitives.js";
import {
encodeToXmlString,
escapePDFName,
escapeString,
getInheritableProperty,
isAscii,
isWhiteSpace,
@ -223,6 +224,14 @@ describe("core_utils", function () {
});
});
describe("escapeString", function () {
it("should escape (, ), \\n, \\r, and \\", function () {
expect(escapeString("((a\\a))\n(b(b\\b)\rb)")).toEqual(
"\\(\\(a\\\\a\\)\\)\\n\\(b\\(b\\\\b\\)\\rb\\)"
);
});
});
describe("encodeToXmlString", function () {
it("should get a correctly encoded string with some entities", function () {
const str = "\"\u0397ell😂' & <W😂rld>";

View file

@ -17,7 +17,6 @@ import {
bytesToString,
createPromiseCapability,
createValidAbsoluteUrl,
escapeString,
getModificationDate,
isArrayBuffer,
string32,
@ -244,14 +243,6 @@ describe("util", function () {
});
});
describe("escapeString", function () {
it("should escape (, ), \\n, \\r, and \\", function () {
expect(escapeString("((a\\a))\n(b(b\\b)\rb)")).toEqual(
"\\(\\(a\\\\a\\)\\)\\n\\(b\\(b\\\\b\\)\\rb\\)"
);
});
});
describe("getModificationDate", function () {
it("should get a correctly formatted date", function () {
const date = new Date(Date.UTC(3141, 5, 9, 2, 6, 53));