Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 3 commits into from Sep 1, 2019
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
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
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
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