mirror of
https://github.com/runkids/skillshare.git
synced 2026-11-20 20:34:19 +00:00
fix(install): keep file:// URLs slash-form on Windows (#346)
parseFileURL cleaned the path with filepath.Clean before prefixing it with `file://`, and on Windows Clean rewrites the separators, so `ss install file:///C:/repos/skills` handed git `file://\C:\repos\skills` and the clone failed. The URL form is slash-based on every platform; only the local-path branches need OS separators. Convert back with filepath.ToSlash and pin the shape with a drive-letter case in the existing table, which fails on Windows without the change and is inert on Unix.
This commit is contained in:
@@ -559,7 +559,10 @@ func parseFileURL(matches []string, source *Source) (*Source, error) {
|
||||
}
|
||||
|
||||
source.Type = SourceTypeGitHTTPS // Treat as git for cloning
|
||||
source.CloneURL = "file://" + path
|
||||
// filepath.Clean rewrites the separators for the local OS, but a file:// URL
|
||||
// keeps forward slashes everywhere; on Windows the raw path would produce
|
||||
// `file://\path\to\repo`, which git does not accept as a local repository.
|
||||
source.CloneURL = "file://" + filepath.ToSlash(path)
|
||||
|
||||
if err := validateCloneURL(source.CloneURL); err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -595,6 +595,13 @@ func TestParseSource_FileURL(t *testing.T) {
|
||||
wantCloneURL: "file:///path/to/repo",
|
||||
wantName: "repo",
|
||||
},
|
||||
{
|
||||
// On Windows filepath.Clean would otherwise emit `file://\C:\...`.
|
||||
name: "file url with a drive path keeps URL separators",
|
||||
input: "file:///C:/path/to/repo",
|
||||
wantCloneURL: "file:///C:/path/to/repo",
|
||||
wantName: "repo",
|
||||
},
|
||||
{
|
||||
name: "file url with dot suffix normalized to root",
|
||||
input: "file:///path/to/repo/.",
|
||||
|
||||
Reference in New Issue
Block a user