1
0
Fork 0
mirror of synced 2024-06-14 08:25:21 +12:00

support negation patterns by checking both re.search and re.match

This commit is contained in:
Nick Sweeting 2021-07-06 23:17:03 -04:00
parent 65d452fe7b
commit e4974d3536

View file

@ -141,7 +141,10 @@ def archivable_links(links: Iterable[Link]) -> Iterable[Link]:
continue
if scheme(link.url) not in ('http', 'https', 'ftp'):
continue
if URL_BLACKLIST_PTN and URL_BLACKLIST_PTN.search(link.url):
if URL_BLACKLIST_PTN and (URL_BLACKLIST_PTN.match(link.url) or URL_BLACKLIST_PTN.search(link.url)):
# https://stackoverflow.com/questions/180986/what-is-the-difference-between-re-search-and-re-match
# we want both behaviors in order to support multiple patterns in the regex,
# and negation regexes like (?!someptnhere) to allow for whitelisting
continue
yield link