fix: do not corrupt location.href when changing deep-linked tabs #12464
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
If HTML page has
<base>
tag, deep-linked tabs currently rewritehref
incorrectly – thepathname
is lost.How to reproduce
It is not possible to set up Codepen demo, because it does not allow history changes (or rather, does not show it in the address bar). However, you can easily reproduce it on a live site.
https://get.foundation/sites/docs/tabs.html#panel1d
changes tohttps://get.foundation/sites/docs/tabs.html#panel2d
etc.<base href="https://get.foundation">
to the<head>
.https://get.foundation/sites/docs/tabs.html#panel1d
now changes tohttps://get.foundation/#panel2d
which is incorrect.This PR fixes it by explicitly using current path and query string to construct new URL. This makes deep-linked tabs handle history consistently with OR without base tag defined.
Types of changes