mirror of
https://github.com/drone-plugins/drone-npm.git
synced 2026-06-14 05:12:29 +08:00
Remove standard http ports from registry URL when writing authToken (#62)
This commit is contained in:
@@ -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, "/") {
|
||||
|
||||
Reference in New Issue
Block a user