mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-08 09:20:06 +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:
parent
e5859e145d
commit
9adc7859c8
6 changed files with 31 additions and 27 deletions
|
@ -1037,20 +1037,6 @@ function stringToPDFString(str) {
|
|||
return strBuf.join("");
|
||||
}
|
||||
|
||||
function escapeString(str) {
|
||||
// replace "(", ")", "\n", "\r" and "\"
|
||||
// by "\(", "\)", "\\n", "\\r" and "\\"
|
||||
// in order to write it in a PDF file.
|
||||
return str.replace(/([()\\\n\r])/g, match => {
|
||||
if (match === "\n") {
|
||||
return "\\n";
|
||||
} else if (match === "\r") {
|
||||
return "\\r";
|
||||
}
|
||||
return `\\${match}`;
|
||||
});
|
||||
}
|
||||
|
||||
function stringToUTF8String(str) {
|
||||
return decodeURIComponent(escape(str));
|
||||
}
|
||||
|
@ -1151,7 +1137,6 @@ export {
|
|||
createPromiseCapability,
|
||||
createValidAbsoluteUrl,
|
||||
DocumentActionEventType,
|
||||
escapeString,
|
||||
FeatureTest,
|
||||
FONT_IDENTITY_MATRIX,
|
||||
FontType,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue