From 197006278d6bfe1d37a22f19be41ed573d66796d Mon Sep 17 00:00:00 2001 From: Benny Siegert Date: Thu, 13 Oct 2022 20:18:34 +0200 Subject: git-codereview: allow trailing slash in git origin An origin like "https://go.googlesource.com/build/" should also work. Perhaps this should use net/url instead of parsing URLs by hand. Change-Id: I5304324ae67c054b8377d500ecafe46b296d1531 Reviewed-on: https://go-review.googlesource.com/c/review/+/442875 Reviewed-by: Heschi Kreinick Run-TryBot: Benny Siegert TryBot-Result: Gopher Robot --- git-codereview/api.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/git-codereview/api.go b/git-codereview/api.go index 7a0da55..947369a 100644 --- a/git-codereview/api.go +++ b/git-codereview/api.go @@ -92,6 +92,8 @@ func loadGerritOriginInternal(origin, remoteOrigin string) error { if !strings.HasPrefix(origin, "https://") { return fmt.Errorf("git origin must be an https:// URL: %s", origin) } + // Remove trailing slash from the origin, if any. + origin = strings.TrimRight(origin, "/") // https:// prefix and then one slash between host and top-level name if strings.Count(origin, "/") != 3 { return fmt.Errorf("git origin is malformed: %s", origin) -- cgit v1.3