From 8d90c952f3b1dbb097a5db53a360c4b59ec4475b Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Tue, 7 Feb 2023 22:24:24 +0800 Subject: [PATCH 1/3] fix --- templates/repo/clone_script.tmpl | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/templates/repo/clone_script.tmpl b/templates/repo/clone_script.tmpl index afd90040fb4e7..10038acd629b7 100644 --- a/templates/repo/clone_script.tmpl +++ b/templates/repo/clone_script.tmpl @@ -17,7 +17,13 @@ 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 host as the clone link + const url = new URL(link); + url.host = window.location.host; + link = url.toString(); + } for (const el of document.getElementsByClassName('js-clone-url')) { el[el.nodeName === 'INPUT' ? 'value' : 'textContent'] = link; } From b5045d709feb4c9773f1daf51fe884f96fd09bd0 Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Wed, 8 Feb 2023 09:43:01 +0800 Subject: [PATCH 2/3] fix url protocol --- templates/repo/clone_script.tmpl | 1 + 1 file changed, 1 insertion(+) diff --git a/templates/repo/clone_script.tmpl b/templates/repo/clone_script.tmpl index 10038acd629b7..715b676277fa2 100644 --- a/templates/repo/clone_script.tmpl +++ b/templates/repo/clone_script.tmpl @@ -21,6 +21,7 @@ if (link.startsWith('http://') || link.startsWith('https://')) { // use current host as the clone link const url = new URL(link); + url.protocol = window.location.protocol; url.host = window.location.host; link = url.toString(); } From bf3067b92ec417bb9118430c819b1acfd4d22bd1 Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Wed, 8 Feb 2023 09:43:49 +0800 Subject: [PATCH 3/3] fix comment --- templates/repo/clone_script.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/repo/clone_script.tmpl b/templates/repo/clone_script.tmpl index 715b676277fa2..88a67d82353b8 100644 --- a/templates/repo/clone_script.tmpl +++ b/templates/repo/clone_script.tmpl @@ -19,7 +19,7 @@ let link = btn.getAttribute('data-link'); if (link.startsWith('http://') || link.startsWith('https://')) { - // use current host as the clone link + // use current protocol/host as the clone link const url = new URL(link); url.protocol = window.location.protocol; url.host = window.location.host;