I've been working on a parser for url queries but I'm stumped on why the regex is incorrect when it worked during test via regex101.com or atleast I think it did, it's been a late night coding;
Anyway I haven't found any answers searching both StackOverflow or Good Ol'e google.
Issue: UnhandledPromiseRejectionWarning: SyntaxError: Invalid regular expression: /\?(?<query>.*)/: Invalid group
const results = url.match(/\?(?<query>.*)/);
if (!results) {
return {};
}
const { groups: { query } } = results;
const pairs = query.match(/(?<param>\w+)=(?<value>\w+)/g);
const params = pairs.reduce((acc, curr) => {
const [key, value] = curr.split(("="));
acc[key] = value;
return acc;
}, {});
return params;