Skip to content

Commit 62e55d0

Browse files
committed
fix dir name handling in Windows for IPv6 addr
1 parent e540fe6 commit 62e55d0

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

api/internal/localizer/util.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,5 +218,10 @@ func parseHost(repoSpec *git.RepoSpec) (string, error) {
218218
return "", errors.Wrap(err)
219219
}
220220
// strip scheme, userinfo, port, and any trailing slashes.
221-
return u.Hostname(), nil
221+
hostname := u.Hostname()
222+
// On Windows, colons are invalid in file paths. Replace them with hyphens
223+
// to make IPv6 addresses filesystem-safe.
224+
// This affects IPv6 addresses like [2001:4860:4860::8888].
225+
hostname = strings.ReplaceAll(hostname, ":", "-")
226+
return hostname, nil
222227
}

api/internal/localizer/util_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ func TestLocRootPath_URLComponents(t *testing.T) {
228228
},
229229
"IPv6": {
230230
urlf: "https://[2001:4860:4860::8888]/org/repo//%s?ref=value",
231-
path: simpleJoin(t, "2001:4860:4860::8888", "org", "repo", "value"),
231+
path: simpleJoin(t, "2001-4860-4860--8888", "org", "repo", "value"),
232232
},
233233
"port": {
234234
urlf: "https://localhost.com:8080/org/repo//%s?ref=value",

0 commit comments

Comments
 (0)