Skip to content

Commit

Permalink
Merge pull request #4785 from jeradrutnam/master
Browse files Browse the repository at this point in the history
Add trailing slash fix to base.html template
  • Loading branch information
jeradrutnam authored Sep 26, 2024
2 parents 795d3a9 + 4ada124 commit 16f22db
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
8 changes: 0 additions & 8 deletions en/theme/material/assets/js/theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,3 @@ dropdownLink.addEventListener('click', function(event) {
event.stopPropagation(); // Prevent the event from propagating to the document
dropdown.classList.toggle('open'); // Toggle the "open" class
});

document.addEventListener('DOMContentLoaded', function () {
// Check if the path does not end with a slash and has no file extension
if (!window.location.pathname.endsWith('/') && !window.location.pathname.split('/').pop().includes('.')) {
var newPath = window.location.pathname + '/' + window.location.search + window.location.hash;
window.history.replaceState({}, document.title, newPath);
}
});
10 changes: 10 additions & 0 deletions en/theme/material/partials/javascripts/base.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<script>__md_scope=new URL("{{ config.extra.scope | d(base_url) }}",location),__md_hash=e=>[...e].reduce(((e,_)=>(e<<5)-e+_.charCodeAt(0)),0),__md_get=(e,_=localStorage,t=__md_scope)=>JSON.parse(_.getItem(t.pathname+"."+e)),__md_set=(e,_,t=localStorage,a=__md_scope)=>{try{t.setItem(a.pathname+"."+e,JSON.stringify(_))}catch(e){}}</script>
<script>
document.addEventListener('DOMContentLoaded', function () {
// Check if the path does not end with a slash and has no file extension
if (!window.location.pathname.endsWith('/') && !window.location.pathname.split('/').pop().includes('.')) {
var newPath = window.location.pathname + '/' + window.location.search + window.location.hash;
window.history.replaceState({}, document.title, newPath);
}
});
</script>

0 comments on commit 16f22db

Please sign in to comment.