mirror of
https://github.com/LukeHagar/libopenapi.git
synced 2025-12-06 12:37:49 +00:00
29 lines
574 B
Go
29 lines
574 B
Go
package utils
|
|
|
|
import (
|
|
"path/filepath"
|
|
"strings"
|
|
)
|
|
|
|
func ReplaceWindowsDriveWithLinuxPath(path string) string {
|
|
if len(path) > 1 && path[1] == ':' {
|
|
path = strings.ReplaceAll(path, "\\", "/")
|
|
return path[2:]
|
|
}
|
|
return strings.ReplaceAll(path, "\\", "/")
|
|
}
|
|
|
|
func CheckPathOverlap(pathA, pathB, sep string) string {
|
|
a := strings.Split(pathA, sep)
|
|
b := strings.Split(pathB, sep)
|
|
if strings.HasPrefix(a[len(a)-1], "/") && a[len(a)-1][1:] == b[0] {
|
|
b = b[1:]
|
|
}
|
|
if a[len(a)-1] == b[0] {
|
|
b = b[1:]
|
|
}
|
|
f := filepath.Join(pathA, strings.Join(b, sep))
|
|
|
|
return f
|
|
}
|