Skip to content

Commit

Permalink
Un de-dupe for client-side file
Browse files Browse the repository at this point in the history
  • Loading branch information
ijjk committed Jan 24, 2020
1 parent accaaba commit ea475c8
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions packages/next/next-server/lib/router/utils/route-regex.ts
@@ -1,13 +1,14 @@
import escapeRegexp from 'escape-string-regexp'

export function getRouteRegex(
normalizedRoute: string
): {
re: RegExp
groups: { [groupName: string]: { pos: number; repeat: boolean } }
} {
// Escape all characters that could be considered RegEx
const escapedRoute = escapeRegexp(normalizedRoute.replace(/\/$/, '') || '/')
const escapedRoute = (normalizedRoute.replace(/\/$/, '') || '/').replace(
/[|\\{}()[\]^$+*?.-]/g,
'\\$&'
)

const groups: { [groupName: string]: { pos: number; repeat: boolean } } = {}
let groupIndex = 1
Expand Down

0 comments on commit ea475c8

Please sign in to comment.