mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-29 10:57:44 +09:00 
			
		
		
		
	Move some regexp out of functions (#25430)
/cc @KN4CK3R https://github.com/go-gitea/gitea/pull/25294#discussion_r1237425343 I also searched the codebase and found a few more. --------- Signed-off-by: jolheiser <john.olheiser@gmail.com>
This commit is contained in:
		| @@ -222,6 +222,8 @@ func isOSWindows() bool { | ||||
| 	return runtime.GOOS == "windows" | ||||
| } | ||||
|  | ||||
| var driveLetterRegexp = regexp.MustCompile("/[A-Za-z]:/") | ||||
|  | ||||
| // FileURLToPath extracts the path information from a file://... url. | ||||
| func FileURLToPath(u *url.URL) (string, error) { | ||||
| 	if u.Scheme != "file" { | ||||
| @@ -235,8 +237,7 @@ func FileURLToPath(u *url.URL) (string, error) { | ||||
| 	} | ||||
|  | ||||
| 	// If it looks like there's a Windows drive letter at the beginning, strip off the leading slash. | ||||
| 	re := regexp.MustCompile("/[A-Za-z]:/") | ||||
| 	if re.MatchString(path) { | ||||
| 	if driveLetterRegexp.MatchString(path) { | ||||
| 		return path[1:], nil | ||||
| 	} | ||||
| 	return path, nil | ||||
|   | ||||
		Reference in New Issue
	
	Block a user