File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -312,9 +312,18 @@ function getRequestURL(req) {
312312 if ( typeof req . getURL === "function" ) {
313313 return req . getURL ( ) ;
314314 }
315- // Fastify decodes URI by default, Our logic is based on encoded URI
316- else if ( typeof req . originalUrl !== "undefined" ) {
317- return req . originalUrl ;
315+
316+ // Fastify decodes URI by default, our logic is based on encoded URI.
317+ // req.originalUrl preserves the original encoded URL; req.url may be
318+ // modified by middleware (e.g. connect-history-api-fallback), in which
319+ // case we re-encode it and use it instead.
320+ if ( typeof req . originalUrl !== "undefined" ) {
321+ const encodedUrl =
322+ typeof req . url !== "undefined" ? encodeURI ( req . url ) : undefined ;
323+
324+ return encodedUrl !== req . originalUrl && encodedUrl !== undefined
325+ ? encodedUrl
326+ : req . originalUrl ;
318327 }
319328
320329 return req . url ;
You can’t perform that action at this time.
0 commit comments