@@ -29,23 +29,23 @@ const {
29
29
30
30
const DATA_URL_PATTERN = / ^ [ ^ / ] + \/ [ ^ , ; ] + (?: [ ^ , ] * ?) ( ; b a s e 6 4 ) ? , ( [ \s \S ] * ) $ / ;
31
31
32
- async function getSource ( url , context ) {
33
- const parsed = new URL ( url ) ;
34
- let responseURL = url ;
32
+ async function getSource ( parsed , context ) {
33
+ const protocol = parsed . protocol ;
34
+ let responseURL = parsed . href ;
35
35
let source ;
36
- if ( parsed . protocol === 'file:' ) {
36
+ if ( protocol === 'file:' ) {
37
37
const { readFile : readFileAsync } = require ( 'internal/fs/promises' ) . exports ;
38
38
source = await readFileAsync ( parsed ) ;
39
- } else if ( parsed . protocol === 'data:' ) {
39
+ } else if ( protocol === 'data:' ) {
40
40
const match = RegExpPrototypeExec ( DATA_URL_PATTERN , parsed . pathname ) ;
41
41
if ( ! match ) {
42
- throw new ERR_INVALID_URL ( url ) ;
42
+ throw new ERR_INVALID_URL ( parsed . href ) ;
43
43
}
44
44
const { 1 : base64 , 2 : body } = match ;
45
45
source = BufferFrom ( decodeURIComponent ( body ) , base64 ? 'base64' : 'utf8' ) ;
46
46
} else if ( experimentalNetworkImports && (
47
- parsed . protocol === 'https:' ||
48
- parsed . protocol === 'http:'
47
+ protocol === 'https:' ||
48
+ protocol === 'http:'
49
49
) ) {
50
50
const { fetchModule } = require ( 'internal/modules/esm/fetch_module' ) ;
51
51
const res = await fetchModule ( parsed , context ) ;
@@ -93,7 +93,7 @@ async function defaultLoad(url, context = kEmptyObject) {
93
93
) {
94
94
source = null ;
95
95
} else if ( source == null ) {
96
- ( { responseURL, source } = await getSource ( url , context ) ) ;
96
+ ( { responseURL, source } = await getSource ( urlInstance , context ) ) ;
97
97
}
98
98
99
99
return {
0 commit comments