1
0
Fork 0
mirror of https://github.com/terribleplan/next.js.git synced 2024-01-19 02:48:18 +00:00
next.js/lib
tangye ab46c45146 should not change method to replaceState unless asPath is the same (#6033)
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.
2019-01-11 18:29:59 +01:00
..
router should not change method to replaceState unless asPath is the same (#6033) 2019-01-11 18:29:59 +01:00
app.js Remove _containerProps context (#5327) 2018-09-29 05:24:27 +02:00
asset.js Handle empty assetPrefix scenario properly. (#3667) 2018-02-03 17:12:01 +01:00
constants.js Rename commons directory to runtime (#4853) 2018-07-27 19:29:25 +02:00
dynamic.js Introduce dynamic(() => import()) (#5249) 2018-09-25 15:27:09 +02:00
error-debug.js Change server error overlay to white to be consistent with react-error-overlay (#5104) 2018-09-05 17:13:44 +02:00
error.js Keep warnings when process.env.NODE_ENV is not production (#5196) 2018-09-18 20:17:35 +02:00
EventEmitter.js Make EventEmitter more Node-like (#4865) 2018-08-01 14:43:25 +02:00
head.js Refactor head keys (#5326) 2018-09-29 06:52:36 +02:00
link.js Move out start method from server (#5315) 2018-09-27 21:10:53 +02:00
loadable-capture.js Split out Loadable.Capture and make NoSSR smaller (#5060) 2018-08-30 15:09:53 +02:00
loadable.js Introduce dynamic(() => import()) (#5249) 2018-09-25 15:27:09 +02:00
p-queue.js improve prefetch (#1161) 2017-02-16 00:59:42 +05:30
page-loader.js Compile pages to .next/static directory (#4828) 2018-07-25 13:45:42 +02:00
promisify.js Move build directory outside of server folder (#4565) 2018-06-14 19:30:14 +02:00
runtime-config.js Exposing configuration to the server / client side (minor) (#3882) 2018-02-26 12:03:27 +01:00
shallow-equals.js Added linting using standard (#27) 2016-10-16 17:00:17 -07:00
side-effect.js Apply sideEffect at DidMount on the client side (#5068) 2018-09-02 19:18:20 +02:00
utils.js Move out start method from server (#5315) 2018-09-27 21:10:53 +02:00