mirror of
https://github.com/terribleplan/next.js.git
synced 2024-01-19 02:48:18 +00:00
ad5431b4ae
original code in `/lib/router/router.js` ``` urlIsNew (pathname, query) { return this.pathname !== pathname || !shallowEquals(query, this.query) } ``` the urlIsNew compare `this.pathname` to an argument `pathname` the invokers: ``` // If asked to change the current URL we should reload the current page // (not location.reload() but reload getInitialProps and other Next.js stuffs) // We also need to set the method = replaceState always // as this should not go into the history (That's how browsers work) if (!this.urlIsNew(asPathname, asQuery)) { method = 'replaceState' } ``` the parameter here is `asPathname` destructured from `asPath` so here is a problem when we reuse a single page rendered in two asPaths pages/a.js ``` <> <Link href='/a'><a>goto a</a></Link> <Link href='/a' as='/b'><a>goto b</a></Link> </> ``` If we navigate to page /a, then click 'goto b', actually the history is replaced, not pushed. It is expected that history could be correctly pushed and popped as long as the browser url is changed. |
||
---|---|---|
.. | ||
dynamic | ||
hmr | ||
nav | ||
nested-cdm | ||
using-asset | ||
async-props.js | ||
custom-encoding.js | ||
custom-extension.jsx | ||
default-head.js | ||
empty-get-initial-props.js | ||
error-in-the-browser-global-scope.js | ||
error-in-the-global-scope.js | ||
error-inside-browser-page.js | ||
error-inside-page.js | ||
exports.js | ||
forwardRef-component.js | ||
fragment-syntax.js | ||
head.js | ||
index.js | ||
instance-get-initial-props.js | ||
json.js | ||
link.js | ||
memo-component.js | ||
no-default-export.js | ||
process-env.js | ||
read-only-object-error.js | ||
stateless.js | ||
styled-jsx.js | ||
url-prop-override.js | ||
url-prop.js | ||
with-cdm.js |