This patch fixes https://github.com/StevenBlack/hosts/issues/1563#issuecomment-810688754
Indeed, before this patch, the updater was not supporting a RAW (not
hosts) list of domains as input.
Changes:
matches_exclusions():
(new) Support for rule formatted as 'example.com' along with
the pre-existing '0.0.0.0 example.com'.
normalize_rule():
(edit) Apply DRY.
(new) Support the normalization of the rule formatted as
'example.com' along with the pre-existing '0.0.0.0
example.com'.
strip_rule():
(new) Complete rewrite in order to strip all possible lines.
Before this patch, there was no proper sorting and the sources.
As @XhmikosR mentioned in StevenBlack/hosts#1166, without this patch,
the output is totally different in Windows. But let's be honest, if it
is like that under Windows, chances are that the same behavior happens
across different OSes or machines around the globe.
Another reason behind this patch is that - desperate the fact that we
certainly trust @StevenBlack - the integrity of the generated files
could not be guarenteed because of the sorting which may be completely
different from an OS to another and a machine to another.
For those reasons, this patch introduces a unification of the sorting of
all sources.
The idea behind this patch is to have @StevenBlack's ad-hoc hosts
file always on top (1st) and the rest of the sources sorted
alphabetically based on the name of the folder inside the `data`
or `extensions` directory.
This will ensure that we get the same result everywhere.
Concretely speaking, I just added the function (`sort_sources`) which
sorts a given list of sources files. And later on, call the new function
everywhere it was necessary. Tests of the newly introduced function
are also included.
Contributors:
* @ScriptTiger
* @XhmikosR
Notes:
* This patch fix (completely ?) ScriptTiger/hosts#1
* This patch fix https://github.com/StevenBlack/hosts/issues/1166#issuecomment-590511086