Skip to content

Commit

Permalink
Fix common base path calculation (#35)
Browse files Browse the repository at this point in the history
A RegExp is being used to subtract out the base path common to "dirname"
and "from", but the "from" path was not being properly escaped for use
in a RegExp. See:

https://developer.mozilla.org/en/docs/Web/JavaScript/Guide/Regular_Expressions
This commit stops npm test from throwing an uncaught exception of type
"RangeError: Maximum call stack size exceeded".
  • Loading branch information
akrawitz committed Sep 26, 2015
1 parent cffd66d commit 59683e5
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,8 @@ function processCopy(result, from, dirname, urlMeta, to, options, decl) {
}
relativeAssetsPath = path.join(
relativeAssetsPath,
dirname.replace(new RegExp(from + "[\/]\?"), ""),
dirname.replace(new RegExp(from.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")
+ "[\/]\?"), ""),
path.dirname(urlMeta.value)
)
absoluteAssetsPath = path.resolve(to, relativeAssetsPath)
Expand Down

0 comments on commit 59683e5

Please sign in to comment.