Moon-0xff/gnome-mpris-label

Weird valid regex

Opened this issue · 2 comments

If user inputs to label-filtered-list entry something like ,,,,,,,,,,,,, is converted to ||||||||||||||| and used as a regex in the line:

const filterRegex = new RegExp("(?:-|\\(|\\[).*(?:" + sanitizedInput.replace(",","|") + ").*(?:$|\\)|\\])","gi");

This is a valid regex, and acts as global wildcard, which is the behaviour I expected, but surely looks like a problematic regex.

Was thinking about this...

Might be better to implement filters in a better way, for example a more "todo list" style such as:
https://www.w3schools.com/howto/howto_js_todolist.asp
image

I'm pretty sure in gnome js, settings can be stored as arrays, so the blacklist can be stored as an array, additionaly the todo list would make it more user friendly.

This removes the annoyances of having a regex, and will fix this bug.

Yes, it would remove the problems of dealing with the values, but implementing the layout itself might be a problem on it's own.

We could try to implement something like this but at this point in time it's better to wait until we can ditch GTK3 compatibility (#62).