|
|
@ -24,14 +24,22 @@ |
|
|
|
const btn = isSSH ? sshBtn : httpsBtn; |
|
|
|
const btn = isSSH ? sshBtn : httpsBtn; |
|
|
|
if (!btn) return; |
|
|
|
if (!btn) return; |
|
|
|
|
|
|
|
|
|
|
|
let link = btn.getAttribute('data-link'); |
|
|
|
// NOTE: Keep this function in sync with the one in the js folder |
|
|
|
if (link.startsWith('http://') || link.startsWith('https://')) { |
|
|
|
function toOriginUrl(urlStr) { |
|
|
|
// use current protocol/host as the clone link |
|
|
|
try { |
|
|
|
const url = new URL(link); |
|
|
|
if (urlStr.startsWith('http://') || urlStr.startsWith('https://') || urlStr.startsWith('/')) { |
|
|
|
url.protocol = window.location.protocol; |
|
|
|
const {origin, protocol, hostname, port} = window.location; |
|
|
|
url.host = window.location.host; |
|
|
|
const url = new URL(urlStr, origin); |
|
|
|
link = url.toString(); |
|
|
|
url.protocol = protocol; |
|
|
|
|
|
|
|
url.hostname = hostname; |
|
|
|
|
|
|
|
url.port = port || (protocol === 'https:' ? '443' : '80'); |
|
|
|
|
|
|
|
return url.toString(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} catch {} |
|
|
|
|
|
|
|
return urlStr; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
const link = toOriginUrl(btn.getAttribute('data-link')); |
|
|
|
|
|
|
|
|
|
|
|
for (const el of document.getElementsByClassName('js-clone-url')) { |
|
|
|
for (const el of document.getElementsByClassName('js-clone-url')) { |
|
|
|
el[el.nodeName === 'INPUT' ? 'value' : 'textContent'] = link; |
|
|
|
el[el.nodeName === 'INPUT' ? 'value' : 'textContent'] = link; |
|
|
|
} |
|
|
|
} |
|
|
|