rsnext/packages/next/next-server/lib/router/utils/escape-path-delimiters.ts
Jan Potoms c9492a8cc9
Relax encoding on dynamic prerendered routes (#14717)
It should be enough to encode the characters that `path-to-regexp` uses as path delimiters (`/#?`).

Fixes https://github.com/vercel/next.js/issues/14691
2020-07-13 14:42:27 +00:00

4 lines
197 B
TypeScript

// escape delimiters used by path-to-regexp
export default function escapePathDelimiters(segment: string): string {
return segment.replace(/[/#?]/g, (char: string) => encodeURIComponent(char))
}