@@ -28,16 +28,6 @@ if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) {
2828 ) ;
2929}
3030
31- const urlRegex = / ^ [ a - z ] [ a - z 0 - 9 \- + . ] + : / i;
32-
33- function parseUrlOrPath ( sourceUrl ) {
34- if ( urlRegex . test ( sourceUrl ) ) {
35- return new URL ( sourceUrl ) ;
36- }
37- const url = process . getBuiltinModule ( "url" ) ;
38- return new URL ( url . pathToFileURL ( sourceUrl ) ) ;
39- }
40-
4131function getReadableStream ( readStream ) {
4232 const { Readable } = process . getBuiltinModule ( "stream" ) ;
4333
@@ -68,9 +58,10 @@ function getArrayBuffer(val) {
6858class PDFNodeStream extends BasePDFStream {
6959 constructor ( source ) {
7060 super ( source , PDFNodeStreamReader , PDFNodeStreamRangeReader ) ;
71- this . url = parseUrlOrPath ( source . url ) ;
61+ const { url } = source ;
62+
7263 assert (
73- this . url . protocol === "file:" ,
64+ url . protocol === "file:" ,
7465 "PDFNodeStream only supports file:// URLs."
7566 ) ;
7667 }
@@ -81,14 +72,13 @@ class PDFNodeStreamReader extends BasePDFStreamReader {
8172
8273 constructor ( stream ) {
8374 super ( stream ) ;
84- const { disableRange, disableStream, length, rangeChunkSize } =
75+ const { disableRange, disableStream, length, rangeChunkSize, url } =
8576 stream . _source ;
8677
8778 this . _contentLength = length ;
8879 this . _isStreamingSupported = ! disableStream ;
8980 this . _isRangeSupported = ! disableRange ;
9081
91- const url = stream . url ;
9282 const fs = process . getBuiltinModule ( "fs" ) ;
9383 fs . promises
9484 . lstat ( url )
@@ -117,7 +107,7 @@ class PDFNodeStreamReader extends BasePDFStreamReader {
117107 } )
118108 . catch ( error => {
119109 if ( error . code === "ENOENT" ) {
120- error = createResponseError ( /* status = */ 0 , url . href ) ;
110+ error = createResponseError ( /* status = */ 0 , url ) ;
121111 }
122112 this . _headersCapability . reject ( error ) ;
123113 } ) ;
@@ -150,8 +140,8 @@ class PDFNodeStreamRangeReader extends BasePDFStreamRangeReader {
150140
151141 constructor ( stream , begin , end ) {
152142 super ( stream , begin , end ) ;
143+ const { url } = stream . _source ;
153144
154- const url = stream . url ;
155145 const fs = process . getBuiltinModule ( "fs" ) ;
156146 try {
157147 const readStream = fs . createReadStream ( url , {
0 commit comments