vue-router icon indicating copy to clipboard operation
vue-router copied to clipboard

fix(history): Resolve the href in `<base>` correctly (#3819)

Open ichaoX opened this issue 1 year ago • 6 comments

  • Resolve the href in <base> correctly.

  • In hash mode, the hash in base is automatically removed and the base trailing slash is distinguished.

  • By default the result of router.resolve().href is the same as the actual switched URL.

Relates to: #3819, #2865

ichaoX avatar Jan 11 '23 05:01 ichaoX

Deploy Preview for vue-router-docs-v3 canceled.

Name Link
Latest commit 992fd4bf226e209ba6791b5abf91734f4ede1d9c
Latest deploy log https://app.netlify.com/sites/vue-router-docs-v3/deploys/646e0bb050065c00085989b1

netlify[bot] avatar Jan 11 '23 05:01 netlify[bot]

Thanks for the PR. Can you provide a failing test or boiled-down repro? Note a base should not contain a hash

posva avatar Jan 12 '23 14:01 posva

An example of reproduction can be found in #3819, and you can view the source code of the Reproduction link.

Some browser extensions or proxies may modify <base>, and as a standard feature of html, it is necessary to support it correctly.

This PR should implement support for almost all legal baseURIs. The <base> tag is then respected after ensuring the prerequisites of availability and consistency . Support base.href containing relative URI or hash, even cross-origin cases.

ichaoX avatar Jan 12 '23 15:01 ichaoX

That base has a hash though. As I said, it cannot have a hash

posva avatar Jan 12 '23 17:01 posva

That reproduction link contains several mistakes at the same time:

  1. incorrect relative path
  2. incorrect hash
  3. there is an extra slash between base and hash

Additional reproduction links:

https://5s3iuf.csb.app/root/path.html

https://5s3iuf.csb.app/root/sameorigin.html

ichaoX avatar Jan 12 '23 18:01 ichaoX

@posva Do you need any other repro?

ichaoX avatar Jan 25 '23 06:01 ichaoX