Skip to content

Commit 55a2d81

Browse files
authored
Merge pull request #293 from toy/fix-duplicate-history
don't push state with same url
2 parents 49d4d32 + 142ad75 commit 55a2d81

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/utils/common-utils.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,11 @@ export function replaceState(rawElementId) {
151151
const newQuery = query.toString().length > 1 ? `${query.toString()}&route=${elementId}` : `route=${elementId}`;
152152

153153
const fragment = `#${currentNavigationHashPart}?${newQuery}`;
154-
const url = new URL(fragment, window.location.href);
155-
window.history.pushState(null, null, url.href);
154+
const currentHref = window.location.href;
155+
const url = new URL(fragment, currentHref);
156+
if (url.href !== currentHref) {
157+
window.history.pushState(null, null, url.href);
158+
}
156159
}
157160

158161
export function toMarkdown(markdownStringRaw) {

0 commit comments

Comments
 (0)