Fix: Canonicalize regex finds
This commit is contained in:
parent
f74da73086
commit
54f58cd7c9
3 changed files with 16 additions and 3 deletions
|
|
@ -16,7 +16,7 @@
|
|||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { PatchReplacement, ReplaceFn } from "./types";
|
||||
import { Patch, PatchReplacement, ReplaceFn } from "./types";
|
||||
|
||||
export function canonicalizeMatch<T extends RegExp | string>(match: T): T {
|
||||
if (typeof match === "string") return match;
|
||||
|
|
@ -55,3 +55,9 @@ export function canonicalizeReplacement(replacement: Pick<PatchReplacement, "mat
|
|||
);
|
||||
Object.defineProperties(replacement, descriptors);
|
||||
}
|
||||
|
||||
export function canonicalizeFind(patch: Patch) {
|
||||
const descriptors = Object.getOwnPropertyDescriptors(patch);
|
||||
descriptors.find = canonicalizeDescriptor(descriptors.find, canonicalizeMatch);
|
||||
Object.defineProperties(patch, descriptors);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue