From edd496b5a8f57e2498ee2b7707a4c831be1cbee4 Mon Sep 17 00:00:00 2001 From: Sean Ryan <16017399+rhiaxion@users.noreply.github.com> Date: Thu, 9 Jun 2022 19:12:45 +0100 Subject: [PATCH] Remove standard http ports from registry URL when writing authToken (#62) --- plugin/impl.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/plugin/impl.go b/plugin/impl.go index 161e86a..3205327 100644 --- a/plugin/impl.go +++ b/plugin/impl.go @@ -10,6 +10,7 @@ import ( "encoding/json" "fmt" "io/ioutil" + "net" "net/url" "os" "os/exec" @@ -297,6 +298,10 @@ func npmrcContentsUsernamePassword(config Settings) string { func npmrcContentsToken(config Settings) string { registry, _ := url.Parse(config.Registry) registry.Scheme = "" // Reset the scheme to empty. This makes it so we will get a protocol relative URL. + host, port, _ := net.SplitHostPort(registry.Host) + if port == "80" || port == "443" { + registry.Host = host // Remove standard ports as they're not supported in authToken since NPM 7. + } registryString := registry.String() if !strings.HasSuffix(registryString, "/") {