Advertisement
Guest User

Untitled

a guest
Jan 24th, 2015
401
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.39 KB | None | 0 0
  1. def validate_url(url, valid_domains_list, strict_https=True):
  2.     uri = urlparse(url)
  3.    
  4.     if strict_https and uri.scheme != 'https':
  5.         return False
  6.    
  7.     domain_validator = lambda domain: uri.netloc == domain or uri.netloc.endswith('.{}'.format(domain))
  8.     return True in map(domain_validator, valid_domains_list)
  9.  
  10. validate_url('https://sandbox.gc.apple.com', ['apple.com'])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement