Skip to content

Commit

Permalink
Do not modify external URLs with segment
Browse files Browse the repository at this point in the history
See #133
  • Loading branch information
agmt committed Aug 24, 2023
1 parent 787b673 commit 0a708f7
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion htmlpreview.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
for (i = 0; i < a.length; ++i) {
href = a[i].href; //Get absolute URL
if (href.indexOf('#') > 0) { //Check if it's an anchor
a[i].href = '//' + location.hostname + location.pathname + location.search + '#' + a[i].hash.substring(1); //Then rewrite URL with support for empty anchor
if ((a[i].protocol + '//' + a[i].hostname + a[i].pathname) == url) { //Rewrite links to this document only
a[i].href = '//' + location.hostname + location.pathname + location.search + '#' + a[i].hash.substring(1); //Then rewrite URL with support for empty anchor
} // Do not modify external URLs with fragment
} else if ((href.indexOf('//raw.githubusercontent.com') > 0 || href.indexOf('//bitbucket.org') > 0) && (href.indexOf('.html') > 0 || href.indexOf('.htm') > 0)) { //Check if it's from raw.github.com or bitbucket.org and to HTML files
a[i].href = '//' + location.hostname + location.pathname + '?' + href; //Then rewrite URL so it can be loaded using CORS proxy
}
Expand Down

0 comments on commit 0a708f7

Please sign in to comment.