jesus2099 / konami-command

power‐ups for various web sites
122 stars 25 forks source link

Duplicate capture group name #844

Closed jesus2099 closed 2 months ago

jesus2099 commented 2 months ago

Unfortunately, Kiwi browser is still stuck on Chromium version 124, which does not handle proper alternative same name capture groups:

Uncaught SyntaxError: 
Invalid regular expression: 
/^(?:.+?[„“«‘] ?(?<release>.+) ?[“”»’] \S+ (?<artists>.+?)|(?<artists>.+?)のリリース(?:グループ)?「(?<release>.+)」) - MusicBrainz$/: 
Duplicate capture group name

bf438b77f834c9bdf56fd3c059163926d725f14e

https://github.com/kiwibrowser/src.next/issues/1121#issuecomment-2285767353

https://caniuse.com/?search=duplicate%20capture%20group%20name

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Regex_duplicate_capture_group_name

jesus2099 commented 2 months ago

OK, as it works in current Firefox for Android 129, I will just use Firefox for MASS MERGE, as long as Kiwi stays in version 124.

jesus2099 commented 2 months ago

I reopen as I have just got 2 new NG reports (but 1 new OK report, as well):

jesus2099 commented 2 months ago

So, all that just to have a cleaner code:

var sregex_title = "(?:.+?[„“«‘] ?(?<release>.+) ?[“”»’] \\S+ (?<artists>.+?)|(?<artists>.+?)のリリース(?:グループ)?「(?<release>.+)」) - MusicBrainz";
var match = document.title.match(new RegExp("^" + sregex_title + "$"));
var release_artists = match.groups.artists;
var release_title = match.groups.release;

But here is the support status of this thing:

It's too cutting edge, too modern. Not widely supported. I think I will have to revert to old school but boring thing like:

var sregex_title = "(?:.+?[„“«‘] ?(.+) ?[“”»’] \\S+ (.+?)|(.+?)のリリース(?:グループ)?「(.+)」) - MusicBrainz";
var match = document.title.match(new RegExp("^" + sregex_title + "$"));
var release_artists = match[2] || match[3];
var release_title = match[1] || match[4];
jesus2099 commented 2 months ago

OK I've worked around the limitation, so that we can still use older browser versions.