Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
this addresses the symptom but the real systemic issue is that prepareDestination is called on rewrite/redirect URLs, which have no defined special behavior for colons and they should not be compiled at all
  • Loading branch information
klarstrup committed Dec 15, 2021
1 parent eda9dfb commit 39545b7
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions packages/next/server/base-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1292,12 +1292,20 @@ export default abstract class Server {
}

if (result.response.headers.has('x-middleware-rewrite')) {
const { newUrl, parsedDestination } = prepareDestination({
const destination = parseUrl(
result.response.headers.get('x-middleware-rewrite')!
)

let { newUrl, parsedDestination } = prepareDestination({
appendParamsToQuery: true,
destination: result.response.headers.get('x-middleware-rewrite')!,
destination: formatUrl({
...destination,
pathname: destination.pathname?.replace(/:/g, '__ESC__COLON__'),
}),
params: _params,
query: parsedUrl.query,
})
newUrl = newUrl.replace(/__ESC__COLON__/g, ':')

if (
parsedDestination.protocol &&
Expand Down

0 comments on commit 39545b7

Please sign in to comment.