ankit / stylebot

Change the appearance of the web instantly
https://stylebot.dev/
MIT License
1.38k stars 205 forks source link

[Bug] Default domain matching sometimes matches on incorrect domains #685

Closed lionel-rowe closed 2 years ago

lionel-rowe commented 2 years ago

Describe the bug

The default domain matching matches when the domain string is found anywhere within the URL, not only when it's the hostname.

Browser

Chrome 97.0.4692.99 on Windows 10

To Reproduce

Steps to reproduce the behavior:

Expected behavior

Background is default (white)

Actual behavior

Background is fuchsia

Additional context

I'm guessing the problem is here: https://github.com/ankit/stylebot/blob/060f566e49c83847d6c4f7e1b87156d91de63a73/src/background/utils.ts#L34-L37

Replacing that indexOf check with something like new URL(url).hostname === new URL(`https://${subUrls[i].trim()}`).hostname might do the trick.

davidgilbertson commented 2 years ago

I just found the same thing, hope to see your PR get merged!