Skip to content

Commit

Permalink
feat(config/presets): handle slash in packageTag (#13028)
Browse files Browse the repository at this point in the history
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
Co-authored-by: Rhys Arkins <rhys@arkins.net>
  • Loading branch information
3 people committed Dec 12, 2021
1 parent dd5edbb commit 4ea9ed2
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
31 changes: 31 additions & 0 deletions lib/config/presets/index.spec.ts
Expand Up @@ -455,6 +455,37 @@ describe('config/presets/index', () => {
packageTag: '1.2.3',
});
});

it('parses local with subdirectory and branch/tag with a slash', () => {
expect(
presets.parsePreset(
'local>PROJECT/repository//path/to/preset#feature/branch'
)
).toEqual({
packageName: 'PROJECT/repository',
params: undefined,
presetName: 'preset',
presetPath: 'path/to',
presetSource: 'local',
packageTag: 'feature/branch',
});
});

it('parses local with sub preset and branch/tag with a slash', () => {
expect(
presets.parsePreset(
'local>PROJECT/repository:preset/subpreset#feature/branch'
)
).toEqual({
packageName: 'PROJECT/repository',
params: undefined,
presetName: 'preset/subpreset',
presetPath: undefined,
presetSource: 'local',
packageTag: 'feature/branch',
});
});

it('parses no prefix as local', () => {
expect(presets.parsePreset('some/repo')).toEqual({
packageName: 'some/repo',
Expand Down
4 changes: 2 additions & 2 deletions lib/config/presets/index.ts
Expand Up @@ -37,10 +37,10 @@ const presetSources: Record<string, PresetApi> = {
};

const nonScopedPresetWithSubdirRegex = regEx(
/^(?<packageName>~?[\w\-./]+?)\/\/(?:(?<presetPath>[\w\-./]+)\/)?(?<presetName>[\w\-.]+)(?:#(?<packageTag>[\w\-.]+?))?$/
/^(?<packageName>~?[\w\-./]+?)\/\/(?:(?<presetPath>[\w\-./]+)\/)?(?<presetName>[\w\-.]+)(?:#(?<packageTag>[\w\-./]+?))?$/
);
const gitPresetRegex = regEx(
/^(?<packageName>[\w\-. /]+)(?::(?<presetName>[\w\-.+/]+))?(?:#(?<packageTag>[\w\-.]+?))?$/
/^(?<packageName>[\w\-. /]+)(?::(?<presetName>[\w\-.+/]+))?(?:#(?<packageTag>[\w\-./]+?))?$/
);

export function replaceArgs(
Expand Down

0 comments on commit 4ea9ed2

Please sign in to comment.