Skip to content

Commit

Permalink
Merge pull request #4790 from jeradrutnam/master
Browse files Browse the repository at this point in the history
Improve trailing slash issue fix
  • Loading branch information
jeradrutnam authored Sep 27, 2024
2 parents ed3e9aa + 2e8504a commit a26cf98
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions en/theme/material/partials/javascripts/base.html
Original file line number Diff line number Diff line change
@@ -1,11 +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>
<!-- Fix for HTML files loads with wrong resource relative paths when the trailing slash is missing -->
<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.location.href = newPath;
}
});
// 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.location.replace(newPath);
}
</script>

<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>

0 comments on commit a26cf98

Please sign in to comment.