2112e81ae4
Fixes https://github.com/zeit/next.js/issues/9678 Co-authored-by: Joe Haddad <timer150@gmail.com>
13 lines
419 B
TypeScript
13 lines
419 B
TypeScript
export function rewriteUrlForNextExport(url: string): string {
|
|
const [pathname, hash] = url.split('#')
|
|
// tslint:disable-next-line
|
|
let [path, qs] = pathname.split('?')
|
|
if (path) {
|
|
path = path.replace(/\/$/, '')
|
|
// Append a trailing slash if this path does not have an extension
|
|
if (!/\.[^/]+\/?$/.test(path)) path += `/`
|
|
}
|
|
if (qs) path += '?' + qs
|
|
if (hash) path += '#' + hash
|
|
return path
|
|
}
|