Skip to content

Commit 4c39964

Browse files
committed
Do not modify external URLs with segment
See htmlpreview#133
1 parent 787b673 commit 4c39964

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

htmlpreview.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@
2222
for (i = 0; i < a.length; ++i) {
2323
href = a[i].href; //Get absolute URL
2424
if (href.indexOf('#') > 0) { //Check if it's an anchor
25-
a[i].href = '//' + location.hostname + location.pathname + location.search + '#' + a[i].hash.substring(1); //Then rewrite URL with support for empty anchor
25+
if ((a[i].protocol + "//" + a[i].hostname + a[i].pathname) == url) { //Rewrite links to this document only
26+
a[i].href = '//' + location.hostname + location.pathname + location.search + '#' + a[i].hash.substring(1); //Then rewrite URL with support for empty anchor
27+
} // Do not modify external URLs with fragment
2628
} 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
2729
a[i].href = '//' + location.hostname + location.pathname + '?' + href; //Then rewrite URL so it can be loaded using CORS proxy
2830
}

0 commit comments

Comments
 (0)