Skip to content

Commit

Permalink
Fixes offline mirror filename calculation for scoped packages URLs in…
Browse files Browse the repository at this point in the history
… Verdaccio (private npm repository) (#7499)

* Fixes offline mirror filename calculation for scoped packages URLs in Verdaccio (private npm repository)

* Fixed test

* Update CHANGELOG.md
  • Loading branch information
xv2 authored and arcanis committed Sep 1, 2019
1 parent 1a57117 commit b8af7e0
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ Please add one entry in this file for each change in Yarn's behavior. Use the sa

## Master

- Fixes the offline mirror filenames when using Verdaccio

[#7499](https://github.com/yarnpkg/yarn/pull/7499) - [**xv2**](https://github.com/xv2)

- Update fixture certificates to prevent false negatives during testing

[#7457](https://github.com/yarnpkg/yarn/pull/7457) - [**Thomas Jouannic**](https://github.com/eilgin)
Expand Down
19 changes: 19 additions & 0 deletions __tests__/fetchers.js
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,25 @@ test('TarballFetcher.fetch properly stores tarball of scoped package in offline
expect(exists).toBe(true);
});

test('TarballFetcher.fetch properly stores tarball of scoped package in offline mirror for Verdaccio', async () => {
const dir = await mkdir('git-fetcher');
const config = await Config.create();
config.registries.yarn.config['yarn-offline-mirror'] = 'test';

const fetcher = new TarballFetcher(
dir,
{
type: 'tarball',
hash: '6f0ab73cdd7b82d8e81e80838b49e9e4c7fbcc44',
reference: 'http://npm.xxxyyyzzz.ru/@types%2fevents/-/events-3.0.0.tgz',
registry: 'npm',
},
config,
);
const cachePath = fetcher.getTarballMirrorPath();
expect(cachePath).toBe(path.join('test', '@types-events-3.0.0.tgz'));
});

test('TarballFetcher.fetch properly stores tarball for scoped package resolved from artifactory registry', async () => {
const dir = await mkdir('tarball-fetcher');
const offlineMirrorDir = await mkdir('offline-mirror');
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 = /\/(?:(@[^/]+)\/)?[^/]+\/(?:-|_attachments)\/(?:@[^/]+\/)?([^/]+)$/;
const RE_URL_NAME_MATCH = /\/(?:(@[^/]+)(?:\/|%2f))?[^/]+\/(?:-|_attachments)\/(?:@[^/]+\/)?([^/]+)$/;

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

0 comments on commit b8af7e0

Please sign in to comment.