fix(pdf): hand pdfjs a file:// standardFontDataUrl; repair Windows CI tests

pdfjs validates standardFontDataUrl as a URL ending in a forward slash —
our raw path with a trailing path.sep is invalid on Windows (C:\...\),
failing extractText/extractImages (and every test that verifies through
them) with 'Invalid factory url: must include trailing slash'. Linux and
macOS passed only because / is also a valid URL slash. Convert with
pathToFileURL() so every platform sends file:///.../standard_fonts/.

Also escape path.sep in PDFBatchOperations' sanitizer test regex — a bare
backslash made new RegExp() a syntax error on Windows.
This commit is contained in:
2026-09-05 23:33:58 +05:30
parent cfe134931f
commit 1b2ab7b55c
2 changed files with 11 additions and 3 deletions
+3 -1
View File
@@ -293,7 +293,9 @@ describe('PDFBatchOperations - runPDFBatchOperation', () => {
operation: 'compress',
outputFolder: path.join(blocker, 'child'),
data: {},
sanitizeError: (message) => message.replace(new RegExp(path.sep, 'g'), '_SANITIZED_'),
// path.sep is "\" on Windows — escape it for RegExp use
sanitizeError: (message) =>
message.replace(new RegExp(path.sep.replace(/\\/g, '\\\\'), 'g'), '_SANITIZED_'),
});
expect(completion.success).toBe(false);