Skip to content

Commit

Permalink
Support NPM Enterprise URLs in offline mirror filename calculation.
Browse files Browse the repository at this point in the history
  • Loading branch information
jmillikin-stripe committed Apr 15, 2019
1 parent 8a671f1 commit 488ae85
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
22 changes: 22 additions & 0 deletions __tests__/fetchers.js
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,28 @@ test('TarballFetcher.fetch properly stores tarball for scoped package resolved f
expect(fetcher.getTarballMirrorPath()).toBe(path.join(offlineMirrorDir, '@exponent-configurator-1.0.2.tgz'));
});

test('TarballFetcher.fetch properly stores tarball for scoped package resolved from npm enterprise registry', async () => {
const dir = await mkdir('tarball-fetcher');
const offlineMirrorDir = await mkdir('offline-mirror');

const config = await Config.create();
config.registries.npm.config['yarn-offline-mirror'] = offlineMirrorDir;

const fetcher = new TarballFetcher(
dir,
{
type: 'tarball',
hash: '6f0ab73cdd7b82d8e81e80838b49e9e4c7fbcc44',
reference:
'https://npm.internal.site:443/@/@exponent/configurator/_attachments/configurator-1.0.2.tgz',
registry: 'npm',
},
config,
);

expect(fetcher.getTarballMirrorPath()).toBe(path.join(offlineMirrorDir, '@exponent-configurator-1.0.2.tgz'));
});

test('TarballFetcher.fetch throws on truncated tar data', async () => {
const dir = await mkdir('tarball-fetcher');
const reporter = new Reporter();
Expand Down
2 changes: 1 addition & 1 deletion src/fetchers/tarball-fetcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const gunzip = require('gunzip-maybe');
const invariant = require('invariant');
const ssri = require('ssri');

const RE_URL_NAME_MATCH = /\/(?:(@[^/]+)\/)?[^/]+\/-\/(?:@[^/]+\/)?([^/]+)$/;
const RE_URL_NAME_MATCH = /\/(?:(@[^/]+)\/)?[^/]+\/(?:-|_attachments)\/(?:@[^/]+\/)?([^/]+)$/;

const isHashAlgorithmSupported = name => {
const cachedResult = isHashAlgorithmSupported.__cache[name];
Expand Down

0 comments on commit 488ae85

Please sign in to comment.