File tree 1 file changed +9
-2
lines changed
1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ import chalk from 'chalk'
3
3
import fs from 'fs'
4
4
import os from 'os'
5
5
import path from 'path'
6
- import { parse as parseUrl } from 'url'
6
+ import { pathToFileURL , URL } from 'url'
7
7
import { FS_PREFIX , DEFAULT_EXTENSIONS , VALID_ID_PREFIX } from './constants'
8
8
import resolve from 'resolve'
9
9
import builtins from 'builtin-modules'
@@ -119,7 +119,14 @@ export function removeImportQuery(url: string) {
119
119
}
120
120
121
121
export function injectQuery ( url : string , queryToInject : string ) {
122
- const { pathname, search, hash } = parseUrl ( url )
122
+ let resolvedUrl = new URL ( url , 'relative:///' )
123
+ if ( resolvedUrl . protocol !== 'relative:' ) {
124
+ resolvedUrl = pathToFileURL ( url )
125
+ }
126
+ let { protocol, pathname, search, hash } = resolvedUrl
127
+ if ( protocol === 'file:' ) {
128
+ pathname = pathname . slice ( 1 )
129
+ }
123
130
return `${ pathname } ?${ queryToInject } ${ search ? `&` + search . slice ( 1 ) : '' } ${
124
131
hash || ''
125
132
} `
You can’t perform that action at this time.
0 commit comments