Skip to content

Commit

Permalink
Add comment on slash normalizing in server (#39653)
Browse files Browse the repository at this point in the history
Documentation / Examples

 Make sure the linting passes by running pnpm lint
 The examples guidelines are followed from our contributing doc

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
ijjk and kodiakhq[bot] committed Aug 16, 2022
1 parent 3f63a49 commit 5061167
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/next/server/base-server.ts
Expand Up @@ -423,6 +423,10 @@ export default abstract class Server<ServerOptions extends Options = Options> {
const urlParts = (req.url || '').split('?')
const urlNoQuery = urlParts[0]

// this normalizes repeated slashes in the path e.g. hello//world ->
// hello/world or backslashes to forward slashes, this does not
// handle trailing slash as that is handled the same as a next.config.js
// redirect
if (urlNoQuery?.match(/(\\|\/\/)/)) {
const cleanUrl = normalizeRepeatedSlashes(req.url!)
res.redirect(cleanUrl, 308).body(cleanUrl).send()
Expand Down

0 comments on commit 5061167

Please sign in to comment.