mirror of
https://github.com/pnpm/pnpm.git
synced 2026-04-11 10:40:53 -04:00
feat(always-auth): add https port parsing on registry matching for artifactory compatibility (#6864)
Co-authored-by: Frederick Engelhardt <frederick.engelhardt@bestbuy.com> Co-authored-by: Zoltan Kochan <z@kochan.io>
This commit is contained in:
committed by
GitHub
parent
09e08a9ae3
commit
aa20818a0e
6
.changeset/yellow-nails-divide.md
Normal file
6
.changeset/yellow-nails-divide.md
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
"@pnpm/network.auth-header": patch
|
||||
"pnpm": patch
|
||||
---
|
||||
|
||||
Authorization token should be found in the configuration, when the requested URL is explicitly specified with a default port (443 on HTTPS or 80 on HTTP) [#6863](https://github.com/pnpm/pnpm/pull/6864).
|
||||
@@ -39,7 +39,7 @@ function getAuthHeaderByURI (authHeaders: Record<string, string>, maxParts: numb
|
||||
|
||||
function removePort (originalUrl: string) {
|
||||
const urlObj = new URL(originalUrl)
|
||||
if (urlObj.port === '') return originalUrl
|
||||
if (urlObj.port === '') return urlObj.href
|
||||
urlObj.port = ''
|
||||
return urlObj.toString()
|
||||
}
|
||||
|
||||
@@ -17,6 +17,17 @@ test('getAuthHeaderByURI()', () => {
|
||||
expect(getAuthHeaderByURI('https://reg.gg:8888/foo/-/foo-1.0.0.tgz')).toBe('Bearer 0000')
|
||||
})
|
||||
|
||||
test('getAuthHeaderByURI() when default ports are specified', () => {
|
||||
const getAuthHeaderByURI = createGetAuthHeaderByURI({
|
||||
allSettings: {
|
||||
'//reg.com/:_authToken': 'abc123',
|
||||
},
|
||||
userSettings: {},
|
||||
})
|
||||
expect(getAuthHeaderByURI('https://reg.com:443/')).toBe('Bearer abc123')
|
||||
expect(getAuthHeaderByURI('http://reg.com:80/')).toBe('Bearer abc123')
|
||||
})
|
||||
|
||||
test('returns undefined when the auth header is not found', () => {
|
||||
expect(createGetAuthHeaderByURI({ allSettings: {}, userSettings: {} })('http://reg.com')).toBe(undefined)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user