aboutsummaryrefslogtreecommitdiffstats
path: root/web_src/js/webcomponents
diff options
context:
space:
mode:
authorsilverwind <me@silverwind.io>2024-02-28 16:04:04 +0100
committerGitHub <noreply@github.com>2024-02-28 15:04:04 +0000
commit82405f808d7b50c3580f26e5ca645e2ed6d284ab (patch)
treef16241dd7850b677188149673d283c430ae93b7a /web_src/js/webcomponents
parent71e0f185f9773d1cc4909867a10c86f74d12ce8d (diff)
downloadgitea-82405f808d7b50c3580f26e5ca645e2ed6d284ab.tar.gz
gitea-82405f808d7b50c3580f26e5ca645e2ed6d284ab.zip
Fix URL calculation in clone input box (#29470)
Ported the function as-is and added comments so we don't forget about this in the future. Fixes: https://github.com/go-gitea/gitea/issues/29462
Diffstat (limited to 'web_src/js/webcomponents')
-rw-r--r--web_src/js/webcomponents/GiteaOriginUrl.js5
1 files changed, 3 insertions, 2 deletions
diff --git a/web_src/js/webcomponents/GiteaOriginUrl.js b/web_src/js/webcomponents/GiteaOriginUrl.js
index 5d71d95c60..6e6f84d739 100644
--- a/web_src/js/webcomponents/GiteaOriginUrl.js
+++ b/web_src/js/webcomponents/GiteaOriginUrl.js
@@ -1,7 +1,8 @@
-// Convert an absolute or relative URL to an absolute URL with the current origin
+// Convert an absolute or relative URL to an absolute URL with the current origin. It only
+// processes absolute HTTP/HTTPS URLs or relative URLs like '/xxx' or '//host/xxx'.
+// NOTE: Keep this function in sync with clone_script.tmpl
export function toOriginUrl(urlStr) {
try {
- // only process absolute HTTP/HTTPS URL or relative URLs ('/xxx' or '//host/xxx')
if (urlStr.startsWith('http://') || urlStr.startsWith('https://') || urlStr.startsWith('/')) {
const {origin, protocol, hostname, port} = window.location;
const url = new URL(urlStr, origin);