This rewrites the domain matching logic to be much faster on checks, but use a bit more memory.
Note that domain matching code is well tested already before this PR, so there's a lot of tests which ensure the safety of this change. New tests were also added to cover the new cases.
Domain matching logic was complex and didn't work in all cases. This caused us to miss an exception allow rule from: https://github.com/brave/brave-browser/issues/2843
This rewrites the domain matching logic to be much faster on checks, but use a bit more memory.
Note that domain matching code is well tested already before this PR, so there's a lot of tests which ensure the safety of this change. New tests were also added to cover the new cases.