forked from forgejo/forgejo
Partial backport of #25430 Not a bug, but worth backporting for efficiency. Signed-off-by: jolheiser <john.olheiser@gmail.com>
This commit is contained in:
parent
203fe2841d
commit
734fd93f59
2 changed files with 6 additions and 4 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue