Commit 90991f17 authored by Arunoda Susiripala's avatar Arunoda Susiripala

Add <page>/index.html url re-writes to next/router.

parent c40ded0c
/* global __NEXT_DATA__ */
import { parse, format } from 'url' import { parse, format } from 'url'
import mitt from 'mitt' import mitt from 'mitt'
import shallowEquals from '../shallow-equals' import shallowEquals from '../shallow-equals'
...@@ -118,7 +120,17 @@ export default class Router { ...@@ -118,7 +120,17 @@ export default class Router {
// If url and as provided as an object representation, // If url and as provided as an object representation,
// we'll format them into the string version here. // we'll format them into the string version here.
const url = typeof _url === 'object' ? format(_url) : _url const url = typeof _url === 'object' ? format(_url) : _url
const as = typeof _as === 'object' ? format(_as) : _as let as = typeof _as === 'object' ? format(_as) : _as
// Add the ending slash to the paths. So, we can serve the
// "<page>/index.html" directly for the SSR page.
const asEndsWithSlash = /\/$/.test(as)
if (
__NEXT_DATA__.nextExport &&
!asEndsWithSlash
) {
as = `${as}/`
}
this.abortComponentLoad(as) this.abortComponentLoad(as)
const { pathname, query } = parse(url, true) const { pathname, query } = parse(url, true)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment