Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def validate_url(url, valid_domains_list, strict_https=True):
- uri = urlparse(url)
- if strict_https and uri.scheme != 'https':
- return False
- domain_validator = lambda domain: uri.netloc == domain or uri.netloc.endswith('.{}'.format(domain))
- return True in map(domain_validator, valid_domains_list)
- validate_url('https://sandbox.gc.apple.com', ['apple.com'])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement