Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Label filtering matches too much #114

Open
Natrium729 opened this issue Dec 5, 2024 · 3 comments
Open

Label filtering matches too much #114

Natrium729 opened this issue Dec 5, 2024 · 3 comments

Comments

@Natrium729
Copy link

When filtering the label to remove segments, the regex matches the first hyphen it finds, possibly removing parts of the title.

For example, if listening to "Trans-Europa Express - 2009 Remaster" (Kraftwerk) with "remaster" filtered out, the first hyphen matches and the track is displayed as "Trans".

A possible fix (that I haven’t tested) is to replace the first .* in this line of label.js

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

with

[^-\\(\\[]*

that is, a run of something that doesn’t contain hyphens or opening brackets, so that we only match the last hyphen or bracket. (My regex is a bit rusty, I might have made some mistakes.)

Thanks for the extension otherwise! :)

@Moon-0xff
Copy link
Owner

Ah, yes. I knew about this bug since I added the filtering feature. It is rare enough (on my testing at least) that I never bothered to fix it.
If you can test this yourself and get it working I would very much accept and appreciate a PR for it.

I'm currently not running GNOME personally, so I'm starting to struggle with new additions to the code, but I'll test and check this when I'm able.

@Natrium729
Copy link
Author

I do agree it's not really high priority. Still, the filtering feature is really nice and a good idea, and I found the bug in about 1 day of using the extension, so worth fixing I think.

I’ve never dabbled in GNOME extension development, that would be a good opportunity. No promises, but I’ll try to make a PR when I have some time.

@Batwam
Copy link
Collaborator

Batwam commented Dec 10, 2024

Wouldn't it be preferable to cut at " - " rather than "-" then?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants