@@ -213,14 +213,24 @@ function tryFsResolve(
213
213
options : InternalResolveOptions ,
214
214
tryIndex = true
215
215
) : string | undefined {
216
- const [ file , q ] = fsPath . split ( `?` , 2 )
217
- const query = q ? `?${ q } ` : ``
216
+ let file = fsPath
217
+ let postfix = ''
218
+
219
+ let postfixIndex = fsPath . indexOf ( '?' )
220
+ if ( postfixIndex < 0 ) {
221
+ postfixIndex = fsPath . indexOf ( '#' )
222
+ }
223
+ if ( postfixIndex > 0 ) {
224
+ file = fsPath . slice ( 0 , postfixIndex )
225
+ postfix = fsPath . slice ( postfixIndex )
226
+ }
227
+
218
228
let res : string | undefined
219
229
for ( const ext of options . extensions || DEFAULT_EXTENSIONS ) {
220
230
if (
221
231
( res = tryResolveFile (
222
232
file + ext ,
223
- query ,
233
+ postfix ,
224
234
options ,
225
235
false ,
226
236
options . tryPrefix
@@ -229,16 +239,17 @@ function tryFsResolve(
229
239
return res
230
240
}
231
241
}
242
+
232
243
if (
233
- ( res = tryResolveFile ( file , query , options , tryIndex , options . tryPrefix ) )
244
+ ( res = tryResolveFile ( file , postfix , options , tryIndex , options . tryPrefix ) )
234
245
) {
235
246
return res
236
247
}
237
248
}
238
249
239
250
function tryResolveFile (
240
251
file : string ,
241
- query : string ,
252
+ postfix : string ,
242
253
options : InternalResolveOptions ,
243
254
tryIndex : boolean ,
244
255
tryPrefix ?: string
@@ -253,14 +264,14 @@ function tryResolveFile(
253
264
return resolvePackageEntry ( file , pkg , options )
254
265
}
255
266
const index = tryFsResolve ( file + '/index' , options )
256
- if ( index ) return index + query
267
+ if ( index ) return index + postfix
257
268
} else {
258
- return normalizePath ( ensureVolumeInPath ( file ) ) + query
269
+ return normalizePath ( ensureVolumeInPath ( file ) ) + postfix
259
270
}
260
271
}
261
272
if ( tryPrefix ) {
262
273
const prefixed = `${ path . dirname ( file ) } /${ tryPrefix } ${ path . basename ( file ) } `
263
- return tryResolveFile ( prefixed , query , options , tryIndex )
274
+ return tryResolveFile ( prefixed , postfix , options , tryIndex )
264
275
}
265
276
}
266
277
0 commit comments