spamscanner / url-regex-safe

Regular expression matching for URL's. Maintained, safe, and browser-friendly version of url-regex. Resolves CVE-2020-7661 for Node.js servers.
https://forwardemail.net/docs/url-regex-javascript-node-js
MIT License
79 stars 16 forks source link

High CPU usage compared to 'url-regex' #6

Closed cbikar closed 3 years ago

cbikar commented 3 years ago

Hi,

We replaced 'url-regex' with 'url-regex-safe' and noticed an unusually high CPU usage. When running the following example code on my machine, 'url-regex' consumes around 1.5% CPU while 'url-regex-safe' consumes 99%. Is this expected?

const urlRegex = require("url-regex");
const urlRegexSafe = require("url-regex-safe");

setInterval(()=> {
    const s = "Test123 http://example.com test..."
    s.match(urlRegex()); // Replace with urlRegexSafe for comparison
}, 10);
niftylettuce commented 3 years ago

The default options are different, check README