From 56777558d1a77dbbf6ac1208089a2be2ca78f26a Mon Sep 17 00:00:00 2001 From: Himanshu Rathod Date: Tue, 9 Oct 2018 11:35:53 -0400 Subject: [PATCH] Allow username in package name Don't fail if a vanity service returns a package name with a SSH url and a username, such as ssh://git@example.com/org/package. --- gosrc/path.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/gosrc/path.go b/gosrc/path.go index 2b0803c6..fdfdf8f8 100644 --- a/gosrc/path.go +++ b/gosrc/path.go @@ -30,7 +30,14 @@ func IsValidRemotePath(importPath string) bool { return false } - if !validHost.MatchString(parts[0]) { + // use only the hostname, if there is a username in the package name + hostparts := strings.Split(parts[0], "@") + host := hostparts[0] + if len(hostparts) > 1 { + host = hostparts[1] + } + + if !validHost.MatchString(host) { return false }