MCPcopy Create free account
hub / github.com/npm/cli / tokenRemoteUrl

Function tokenRemoteUrl

scripts/create-node-pr.js:109–118  ·  view source on GitHub ↗
({ host, token })

Source from the content-addressed store, hash-verified

107}
108
109const tokenRemoteUrl = ({ host, token }) => {
110 // this is a remote url that uses a github token as the username
111 // in order to authenticate with github
112 const headRemoteUrl = new URL(host.https())
113 headRemoteUrl.username = token
114 // we have to manually change the protocol. the whatwg url spec
115 // does not allow changing a special protocol to another one
116 // but the protocol has to be `https:` without the `git+`
117 return headRemoteUrl.toString().replace('git+https:', 'https:')
118}
119
120const main = async (spec, branch = 'main', opts) => withTempDir(CWD, async (tmpDir) => {
121 const { GITHUB_TOKEN } = process.env

Callers 1

mainFunction · 0.85

Calls 2

replaceMethod · 0.80
toStringMethod · 0.45

Tested by

no test coverage detected