Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/plugins/url/UrlPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,9 @@ export class UrlPlugin {
}

if (this.urlMode == 'hash') {
window.location.replace('#' + concatenatedPath);
// Use location.hash instead of location.replace('#...') to preserve
// the current pathname in SPA contexts.
window.location.hash = concatenatedPath;
}
this.oldLocationHash = urlStrPath;
}
Expand Down
5 changes: 4 additions & 1 deletion src/plugins/url/plugin.url.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,10 @@ BookReader.prototype.urlUpdateFragment = function() {
} else if (this.textFragmentPage && extractedPage != this.textFragmentPage) {
textFragment = '';
}
window.location.replace('#' + newFragment + newQueryStringSearch + textFragment);
// Use location.hash instead of location.replace('#...') to preserve
// the current pathname. location.replace('#foo') is a relative URL
// that can wipe the path in SPA contexts.
window.location.hash = newFragment + newQueryStringSearch + textFragment;
this.oldLocationHash = newFragment + newQueryStringSearch + textFragment;
}
};
Expand Down
Loading