mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-10 12:49:52 +01:00
Make clone URL use current page's host (#22808)
Follow #21986 Even if the ROOT_URL is incorrect, the clone URL on the UI should be correct. --------- Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
This commit is contained in:
parent
7ae10cb7f1
commit
29aea3642f
1 changed files with 8 additions and 1 deletions
|
@ -17,7 +17,14 @@
|
|||
const btn = isSSH ? sshBtn : httpsBtn;
|
||||
if (!btn) return;
|
||||
|
||||
const link = btn.getAttribute('data-link');
|
||||
let link = btn.getAttribute('data-link');
|
||||
if (link.startsWith('http://') || link.startsWith('https://')) {
|
||||
// use current protocol/host as the clone link
|
||||
const url = new URL(link);
|
||||
url.protocol = window.location.protocol;
|
||||
url.host = window.location.host;
|
||||
link = url.toString();
|
||||
}
|
||||
for (const el of document.getElementsByClassName('js-clone-url')) {
|
||||
el[el.nodeName === 'INPUT' ? 'value' : 'textContent'] = link;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue