Skip to content

Commit

Permalink
Update regex strings
Browse files Browse the repository at this point in the history
  • Loading branch information
davwheat authored and dsevillamartin committed Oct 30, 2021
1 parent 4a50541 commit 9c1fb86
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions js/src/common/utils/proxifyCompat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ export default function proxifyCompat(compat: Record<string, unknown>, namespace
// and remove .js, .ts and .tsx extensions
// e.g. admin/utils/extract --> utils/extract
// e.g. tags/common/utils/sortTags --> tags/utils/sortTags
const regex = new RegExp(`^(.+\/)?(${namespace}|common)\/`);
const fileExt = /\.(\.js|\.tsx?)$/;
const regex = new RegExp(String.raw`(\w+\/)?(${namespace}|common)\/`);
const fileExt = /(\.js|\.tsx?)$/;

return new Proxy(compat, {
get: (obj, prop: string) => obj[prop] || obj[prop.replace(regex, '$1').replace(fileExt, '')],
Expand Down

0 comments on commit 9c1fb86

Please sign in to comment.