fix #12255
When looking for common suffixes, strip the common prefix (if any) from the items, so that the method doesn't fail when they overlap.
This commit is contained in:
parent
eb58387a39
commit
39adecf568
|
@ -134,7 +134,9 @@ const itemsToRegexp = itemsArr => {
|
|||
// special case for 2 items with common prefix/suffix
|
||||
if (finishedItems.length === 0 && items.size === 2) {
|
||||
const prefix = getCommonPrefix(itemsArr);
|
||||
const suffix = getCommonSuffix(itemsArr);
|
||||
const suffix = getCommonSuffix(
|
||||
itemsArr.map(item => item.substring(prefix.length))
|
||||
);
|
||||
if (prefix.length > 0 || suffix.length > 0) {
|
||||
return `${quoteMeta(prefix)}${itemsToRegexp(
|
||||
itemsArr.map(i => i.slice(prefix.length, -suffix.length || undefined))
|
||||
|
|
|
@ -77,4 +77,16 @@ describe("itemsToRegexp", () => {
|
|||
`(\\.\\/path\\/to\\/(directory\\/with\\/(file\\.(js(|on)|css)|module\\.css)|file\\.(|m)js|other\\-file\\.js)|webpack\\/runtime\\/module)`
|
||||
)
|
||||
);
|
||||
|
||||
expectCompiled(
|
||||
"prefix and suffix overlap",
|
||||
[
|
||||
"webpack_sharing_consume_default_react_react",
|
||||
"webpack_sharing_consume_default_classnames_classnames-webpack_sharing_consume_default_react_react"
|
||||
],
|
||||
e =>
|
||||
e.toMatchInlineSnapshot(
|
||||
`webpack_sharing_consume_default_(|classnames_classnames\\-webpack_sharing_consume_default_)react_react`
|
||||
)
|
||||
);
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue