Skip to content

Commit

Permalink
fix: ineffective regex
Browse files Browse the repository at this point in the history
  • Loading branch information
pablo1v committed Feb 24, 2021
1 parent b74a4c3 commit 6325f6c
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions jest/resolvePaths.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
const { join } = require('path');

const SLASH_REGEX = /\/\*$/g;

/**
Expand All @@ -8,13 +6,13 @@ const SLASH_REGEX = /\/\*$/g;
* @return {{ [key: string]: string }}
*/
function resolvePaths(paths, basePath = '/') {
const basePathParsed = join('<rootDir>', basePath).replace(/\\/, '/');
const basePathWithRoot = `<rootDir>/${basePath}`;

return Object.entries(paths).reduce((currentPathsObject, [name, path]) => {
const nameParsed = `^${clean(name, '/')}(.*)$`;
const pathParsed = []
.concat(path)
.map(value => `${basePathParsed}/${clean(value, '')}/$1`);
.map(value => `${basePathWithRoot}/${clean(value, '')}/$1`);

return Object.assign(currentPathsObject, {
[nameParsed]: pathParsed,
Expand Down

0 comments on commit 6325f6c

Please sign in to comment.