Skip to content

Commit f9ac4ec

Browse files
committed
navigate to complete url instead of only fragment/hash
Using only fragment works completely fine unless base tag is added in head (which makes also pushState urls be relative to it instead of to the current url). Fix by constructing complete url relative to current location.
1 parent 24fb723 commit f9ac4ec

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/utils/common-utils.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,10 @@ export function replaceState(rawElementId) {
149149
const query = new URLSearchParams(currentQuery);
150150
query.delete('route');
151151
const newQuery = query.toString().length > 1 ? `${query.toString()}&route=${elementId}` : `route=${elementId}`;
152-
window.history.pushState(null, null, `#${currentNavigationHashPart}?${newQuery}`);
152+
153+
const fragment = `#${currentNavigationHashPart}?${newQuery}`;
154+
const url = new URL(fragment, window.location.href);
155+
window.history.pushState(null, null, url.href);
153156
}
154157

155158
export function toMarkdown(markdownStringRaw) {

0 commit comments

Comments
 (0)