Skip to content

Commit

Permalink
fix: Fix path resolution when the alias is not a proper sub path (#177)
Browse files Browse the repository at this point in the history
  • Loading branch information
fatfisz authored and tleunen committed May 16, 2017
1 parent d4d464f commit dcd5dca
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/normalizeOptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ function normalizeAlias(opts) {
opts.alias = aliasKeys.map(key => (
isRegExp(key) ?
getAliasPair(key, alias[key]) :
getAliasPair(`^${key}((?:/|).*)`, `${alias[key]}\\1`)
getAliasPair(`^${key}(/.*|)$`, `${alias[key]}\\1`)
));
} else {
opts.alias = [];
Expand Down
16 changes: 16 additions & 0 deletions test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,14 @@ describe('module-resolver', () => {
);
});

it('should not alias if there is no proper sub path', () => {
testWithImport(
'components_dummy',
'components_dummy',
aliasTransformerOpts,
);
});

it('should alias the sub file path', () => {
testWithImport(
'test/tools',
Expand All @@ -292,6 +300,14 @@ describe('module-resolver', () => {
);
});

it('should not alias if there is no proper sub path', () => {
testWithImport(
'awesome/componentss',
'awesome/componentss',
aliasTransformerOpts,
);
});

it('should alias the sub file path', () => {
testWithImport(
'awesome/components/Header',
Expand Down

0 comments on commit dcd5dca

Please sign in to comment.