RandomSec/docs/static/js/fix-location.js
Antonin Delpeuch ee72a200e1
Remove trailing slashes in doc pages URLs to fix links. (#3821)
* Improve broken link detection, remove trailing slashes from URLs.

Closes #3819.

* Preserve hash when removing trailing slash in URL
2021-04-24 15:33:24 +02:00

9 lines
447 B
JavaScript

/*
* when trailing slashes are added to URLs, this breaks internal links.
* This is a fix for this issue taken from:
* https://github.com/facebook/docusaurus/issues/2394#issuecomment-630638096
*/
if (window && window.location && window.location.pathname.endsWith('/') && window.location.pathname !== '/') {
window.history.replaceState('', '', window.location.pathname.substr(0, window.location.pathname.length - 1) + window.location.hash)
}