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

Feature request: Support Subdomains #69

Closed
Zeeex opened this issue Dec 9, 2023 · 3 comments · Fixed by #70
Closed

Feature request: Support Subdomains #69

Zeeex opened this issue Dec 9, 2023 · 3 comments · Fixed by #70
Labels
enhancement New feature or request
Milestone

Comments

@Zeeex
Copy link

Zeeex commented Dec 9, 2023

Hello, this extension is working great, thanks for that, and I was thinking it can be improved even more.

Currently we can only block full URL and domains in general, but option to block (include) subdomains is not available.

Scenario: Let's say I want to block all URLs from one domain, and all subdomains that come from it.
Example URL: "https://onepunchman.fandom.com"
I can only block "fandom.com", and it works fine on that specific site, but it doesn't block any subpages.

  1. It could be improved by implementing wildcards support, like this:
    *.fandom.com
  2. Or when we add "fandom.com", it automatically includes subdomains as well

But i'd prefer option 1, because it gives us the control to choose.

@penge
Copy link
Owner

penge commented Dec 10, 2023

Hi @Zeeex

Thank you for the suggestions. Support for both subdomains and wildcards definitely sounds nice, and I am keen on adding them both. Let's see what would be the best way to approach.

Blocking subdomains

Because wildcard in DNS does not cover root domain, *.fandom.com would block only subdomains, but not fandom.com. To block them both, both would need to be stated:

fandom.com
*.fandom.com

I think this is the control you were referring to. No hidden behaviour as well. To block only subdomains:

*.fandom.com

And to block all subdomains except one:

*.fandom.com
!pokemon.fandom.com

Can we agree this is the behaviour we would want?

Wildcards support

Besides blocking subdomains, wildcard could be used anywhere in the path, to match any directory for example. The following example would block all topics:

fandom.com/topics/*

And similarly, to block all topics except one:

fandom.com/topics/*
!fandom.com/topics/anime

Can we agree this is the behaviour we would want?

@Zeeex
Copy link
Author

Zeeex commented Dec 10, 2023

Absolutely, both blocking subdomains and wildcard support are fantastic additions! Excellent examples as well.

I'm eagerly anticipating this implementation.

@penge penge added the enhancement New feature or request label Dec 12, 2023
@penge penge added this to the 8.0 milestone Dec 12, 2023
@penge
Copy link
Owner

penge commented Dec 14, 2023

Hi again @Zeeex

I have it implemented. Also added support for matching any one character using ?.

Note:
With the addition of * and ?, blocked sites no longer expand automatically. That means, blocking youtube.com does NOT block any page on youtube.com, but only youtube.com and that's it. To block youtube.com AND any page on it, we would have to write youtube.com/*.
To make it convenient for the user to block the homepage only, he can write either youtube.com or youtube.com/.

Please, feel free to check out #70. The most important file to look at, is find-rule.test.ts, where are all the test scenarios I could think of. It would be nice to double check on that!
I have also added Examples section to README.

@penge penge closed this as completed in #70 Dec 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants