I see that you've just copied this code, but it seems `if allowed` could be added to every `if` to avoid extra computations. Or it can be rewritten like

```
if self.allow_res and not _matches(link.url, self.allow_res):
    return False
if self.deny_res and _matches(link.url, self.deny_res):
    return False
# ...
```
Also, modifying `link.url` in `_link_allowed` method is bad. 
Feel free to ignore this all because it is not relevant for this PR :)