mirror of
https://github.com/runkids/skillshare.git
synced 2026-11-20 12:23:22 +00:00
fix(install): treat file://localhost URLs as local clone sources
Git clones file://localhost/path from the local filesystem, but the containment guard only recognised an empty authority, so --track --force could still delete a source given that way. Accept localhost (any case) as local.
This commit is contained in:
@@ -28,7 +28,8 @@ func localCloneSource(source *Source) string {
|
||||
return source.Path
|
||||
}
|
||||
u, err := url.Parse(source.CloneURL)
|
||||
if err != nil || u.Scheme != "file" || u.Host != "" {
|
||||
// file://localhost/path is the same local path as file:///path.
|
||||
if err != nil || u.Scheme != "file" || (u.Host != "" && !strings.EqualFold(u.Host, "localhost")) {
|
||||
return ""
|
||||
}
|
||||
// file:///C:/repo carries the drive after a leading slash.
|
||||
|
||||
@@ -325,6 +325,7 @@ func TestInstallTrackedRepo_RefusesLocalSourceInsideTheDestination(t *testing.T)
|
||||
{"same path", "", func(p string) string { return p }, false},
|
||||
{"nested path", "nested", func(p string) string { return p }, false},
|
||||
{"explicit file URL", "nested", func(p string) string { return fileURL(p) }, false},
|
||||
{"localhost file URL", "nested", func(p string) string { return "file://localhost" + p }, false},
|
||||
{"dry run", "nested", func(p string) string { return p }, true},
|
||||
}
|
||||
for _, tc := range cases {
|
||||
|
||||
Reference in New Issue
Block a user