mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-11-03 20:36:07 +01:00 
			
		
		
		
	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
This commit is contained in:
		@@ -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);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user