Closed kvpt closed 3 years ago
Right now the script only works with literal expressions partial-matching to whole lines. I do plan to offer regular expressions in the future (https://github.com/ScriptTiger/Unified-Hosts-AutoUpdate/issues/8) when I can dedicate the appropriate time and attention needed to revisit this. However, literal expressions seem to be the easiest for most people, despite their shortcomings, because they don't require any special characters or syntax and inherently imply wild cards at the beginning and ending of an expression when partial-matching.
Consider the example you have presented:
0.0.0.0 .reddit.
0.0.0.0 .redditstatic.
0.0.0.0 .redd.it
Because the script only works on literal expression and because you included a leading 0.0.0.0
, it will search for lines that partial-match exactly to the expression 0.0.0.0 .reddit.
. There is no implied wild card between 0.0.0.0
and .reddit.
. Implied wild cards only occur at the beginning and ending of a literal expression when partial-matching. In your case, please try the following instead:
.reddit.
.redditstatic.
.redd.it
If you would like more granularity, you can include the leading 0.0.0.0
followed by all of the specific entries you would like to ignore:
0.0.0.0 reddit.com
0.0.0.0 www.reddit.com
Again, the main thing to note here is there are only implied wild cards at the beginning and ending of an expression, not in the middle. This is not only a limitation with the script, but also a limitation with the hosts file format itself, as the hosts file format itself does not support wild cards of any type and exactly matches to domain names as literal expressions. However, as I stated above, I do plan to implement regular expressions in the future for even greater granularity, but this will still just be working around the limitation the hosts file format itself inherently possesses.
Please let me know if this addresses your issue, and feel free to close this issue if so.
I tested the two syntaxes, with and without the ip before and it's doesn't works in one case or another. But if I add a complete entry like
mod.reddit.com
mod.reddit.com is ignored, but it is not by just .reddit. Am I missing something ? Is it possible to debug it be modifying the script ?
Can you confirm you have no leading or trailing spaces on the line .reddit.
? If you have confirmed mod.reddit.com
works, there shouldn't be any reason why .reddit.
wouldn't. Please remember the entire line of text is a single literal expression, so it includes any and all white space or other characters you have included on the line. Comment characters are also not recognized, such as "#". So, if you have included any comments on the line, please remove those, as well.
Ok, I made some more tests and I had to add more rules to match all the case. And also .reddit. rule seems to work now and match mod.reddit.com. So it was an issue somewhere on my side. Sorry for the disturbance and thanks for the support and your very convenient script.
No worries. A script is only as useful as it is understood how to use it, so usability and user experience are definitely important components. We've had plenty of issues related to this in the past, as well as just the many pitfalls of using literal expressions versus regular expressions. So there's definitely going to be some backwards compatible changes made to this in the future so current configs will work, but also give people some new options at the same time.
Hi,
Thanks for your script. I have a problem with the ignore functionality, I can't get the ignore entries to work. I have deleted the scheduled task and the host file and re-launched the update form scratch, same result.
Script version is 1.48 1e7da3074efb54cbfa2277554a761f55028617b7 (so the latest). OS version is Windows 10 20H2. Scheduled task seems to work fine and no error in the log.
Here the content of my ignore.txt file:
I use this host file.
The reddit entries are still present in the hostfile. I also try to use compression level 1 and 9, same issue.