Files
6253e74f93 fix: improve duplicate named groups check (#17176)
* fix: improve duplicate named groups check

* Update packages/babel-helper-create-regexp-features-plugin/src/util.ts

Co-authored-by: Nicolò Ribaudo <[email protected]>

* Update packages/babel-helper-create-regexp-features-plugin/test/util.skip-bundled.js

---------

Co-authored-by: Nicolò Ribaudo <[email protected]>
2025-03-12 11:39:35 -04:00

15 lines
521 B
JavaScript

import { generateRegexpuOptions } from "../lib/util.js";
describe("generateRegexpuOptions", () => {
describe("should handle maliciously crafted pattern", () => {
it("\\(?<\\(?<...", () => {
const pattern = "" + new RegExp("\\(?<".repeat(4e4));
const startTime = Date.now();
const options = generateRegexpuOptions(pattern, 0);
const timeTaken = Date.now() - startTime;
expect(timeTaken).toBeLessThan(2000);
expect(options).toHaveProperty("namedGroups", false);
});
});
});