diff --git a/templates/repo/clone_script.tmpl b/templates/repo/clone_script.tmpl
index afd90040fb..88a67d8235 100644
--- a/templates/repo/clone_script.tmpl
+++ b/templates/repo/clone_script.tmpl
@@ -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;
 		}