1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-21 23:58:07 +02:00

Move the encodeToXmlString helper function to src/core/core_utils.js

With the previous patch this function is now *only* accessed on the worker-thread, hence it's no longer necessary to include it in the *built* `pdf.js` file.
This commit is contained in:
Jonas Jenwald 2021-02-16 14:13:51 +01:00
parent b66f294f64
commit d366bbdf51
5 changed files with 62 additions and 64 deletions

View file

@ -15,6 +15,7 @@
import { Dict, Ref } from "../../src/core/primitives.js";
import {
encodeToXmlString,
escapePDFName,
getInheritableProperty,
isWhiteSpace,
@ -218,4 +219,18 @@ describe("core_utils", function () {
);
});
});
describe("encodeToXmlString", function () {
it("should get a correctly encoded string with some entities", function () {
const str = "\"\u0397ell😂' & <W😂rld>";
expect(encodeToXmlString(str)).toEqual(
"&quot;&#x397;ell&#x1F602;&apos; &amp; &lt;W&#x1F602;rld&gt;"
);
});
it("should get a correctly encoded basic ascii string", function () {
const str = "hello world";
expect(encodeToXmlString(str)).toEqual(str);
});
});
});

View file

@ -17,7 +17,6 @@ import {
bytesToString,
createPromiseCapability,
createValidAbsoluteUrl,
encodeToXmlString,
escapeString,
getModificationDate,
isArrayBuffer,
@ -335,20 +334,6 @@ describe("util", function () {
});
});
describe("encodeToXmlString", function () {
it("should get a correctly encoded string with some entities", function () {
const str = "\"\u0397ell😂' & <W😂rld>";
expect(encodeToXmlString(str)).toEqual(
"&quot;&#x397;ell&#x1F602;&apos; &amp; &lt;W&#x1F602;rld&gt;"
);
});
it("should get a correctly encoded basic ascii string", function () {
const str = "hello world";
expect(encodeToXmlString(str)).toEqual(str);
});
});
describe("isAscii", function () {
it("handles ascii/non-ascii strings", function () {
expect(isAscii("hello world")).toEqual(true);