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 <heschi@google.com>
Run-TryBot: Benny Siegert <bsiegert@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
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 @@
 		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)