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:
star-nebula
2026-10-03 12:53:34 +08:00
committed by GitHub
parent b931c2aeca
commit 95f54f233c
2 changed files with 11 additions and 1 deletions
+4 -1
View File
@@ -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
+7
View File
@@ -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/.",