Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions __tests__/commands/install/integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,20 @@ test('install a scoped module from authed private registry', (): Promise<void> =
});
});

test('install a scoped module from authed private registry with a missing trailing slash', (): Promise<void> => {
return runInstall({noLockfile: true}, 'install-from-authed-private-registry-no-slash', async (config) => {
const authedRequests = request.__getAuthedRequests();
assert.equal(authedRequests[0].url, 'https://registry.yarnpkg.com/@types%2flodash');
assert.equal(authedRequests[0].headers.authorization, 'Bearer abc123');
assert.equal(authedRequests[1].url, 'https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.37.tgz');
assert.equal(authedRequests[1].headers.authorization, 'Bearer abc123');
assert.equal(
(await fs.readFile(path.join(config.cwd, 'node_modules', '@types', 'lodash', 'index.d.ts'))).split('\n')[0],
'// Type definitions for Lo-Dash 4.14',
);
});
});

test.concurrent('install a module with incompatible optional dependency should skip dependency',
(): Promise<void> => {
return runInstall({}, 'install-should-skip-incompatible-optional-dep', async (config) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
//registry.yarnpkg.com/:_authToken=abc123
@types:registry=https://registry.yarnpkg.com
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"dependencies": {
"@types/lodash": "4.14.37"
}
}
2 changes: 1 addition & 1 deletion src/registries/npm-registry.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ export default class NpmRegistry extends Registry {
registry = registry.replace(/^https?:/, '');

// Check for bearer token.
let auth = this.getScopedOption(registry, '_authToken');
let auth = this.getScopedOption(registry.replace(/\/?$/, '/'), '_authToken');
if (auth) {
return `Bearer ${String(auth)}`;
}
Expand Down