Skip to content

Commit 4ad8816

Browse files
jmillikin-stripearcanis
authored andcommitted
Support NPM Enterprise URLs in offline mirror filename calculation. (#7200)
* Support NPM Enterprise URLs in offline mirror filename calculation. * Update CHANGELOG.md * Update CHANGELOG.md
1 parent 8a671f1 commit 4ad8816

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ Please add one entry in this file for each change in Yarn's behavior. Use the sa
2020

2121
[#7127](https://github.com/yarnpkg/yarn/pull/7127) - [**Eli Perelman**](https://github.com/eliperelman)
2222

23+
- Adds support for the npm enterprise URLs when computing the offline mirror filenames.
24+
25+
[#7200](https://github.com/yarnpkg/yarn/pull/7200) - [**John Millikin**](https://john-millikin.com)
26+
2327
## 1.15.2
2428

2529
The 1.15.1 doesn't exist due to a release hiccup.

__tests__/fetchers.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,27 @@ test('TarballFetcher.fetch properly stores tarball for scoped package resolved f
322322
expect(fetcher.getTarballMirrorPath()).toBe(path.join(offlineMirrorDir, '@exponent-configurator-1.0.2.tgz'));
323323
});
324324

325+
test('TarballFetcher.fetch properly stores tarball for scoped package resolved from npm enterprise registry', async () => {
326+
const dir = await mkdir('tarball-fetcher');
327+
const offlineMirrorDir = await mkdir('offline-mirror');
328+
329+
const config = await Config.create();
330+
config.registries.npm.config['yarn-offline-mirror'] = offlineMirrorDir;
331+
332+
const fetcher = new TarballFetcher(
333+
dir,
334+
{
335+
type: 'tarball',
336+
hash: '6f0ab73cdd7b82d8e81e80838b49e9e4c7fbcc44',
337+
reference: 'https://npm.internal.site:443/@/@exponent/configurator/_attachments/configurator-1.0.2.tgz',
338+
registry: 'npm',
339+
},
340+
config,
341+
);
342+
343+
expect(fetcher.getTarballMirrorPath()).toBe(path.join(offlineMirrorDir, '@exponent-configurator-1.0.2.tgz'));
344+
});
345+
325346
test('TarballFetcher.fetch throws on truncated tar data', async () => {
326347
const dir = await mkdir('tarball-fetcher');
327348
const reporter = new Reporter();

src/fetchers/tarball-fetcher.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const gunzip = require('gunzip-maybe');
1818
const invariant = require('invariant');
1919
const ssri = require('ssri');
2020

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

2323
const isHashAlgorithmSupported = name => {
2424
const cachedResult = isHashAlgorithmSupported.__cache[name];

0 commit comments

Comments
 (0)