anchor: fix link in FF when served from filesystem #482

This commit is contained in:
Sören Weber 2023-02-20 13:54:45 +01:00
parent 1e670e8f3d
commit 68e89ca171
No known key found for this signature in database
GPG key ID: BEC6D55545451B6D

View file

@ -305,7 +305,7 @@ function initSwagger( update, attrs ){
function initAnchorClipboard(){ function initAnchorClipboard(){
document.querySelectorAll( 'h1~h2,h1~h3,h1~h4,h1~h5,h1~h6').forEach( function( element ){ document.querySelectorAll( 'h1~h2,h1~h3,h1~h4,h1~h5,h1~h6').forEach( function( element ){
var url = encodeURI(document.location.origin + document.location.pathname); var url = encodeURI( (document.location.origin == "null" ? (document.location.protocol + "//" + document.location.host) : document.location.origin )+ document.location.pathname);
var link = url + "#" + element.id; var link = url + "#" + element.id;
var new_element = document.createElement( 'span' ); var new_element = document.createElement( 'span' );
new_element.classList.add( 'anchor' ); new_element.classList.add( 'anchor' );