diff options
author | silverwind <me@silverwind.io> | 2024-02-28 16:04:04 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-28 15:04:04 +0000 |
commit | 82405f808d7b50c3580f26e5ca645e2ed6d284ab (patch) | |
tree | f16241dd7850b677188149673d283c430ae93b7a /web_src/js/webcomponents | |
parent | 71e0f185f9773d1cc4909867a10c86f74d12ce8d (diff) | |
download | gitea-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.js | 5 |
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); |