From de5987bda08c6d53fb0390b71cb60b24e9deddb4 Mon Sep 17 00:00:00 2001 From: Craig Tracey Date: Sat, 28 Dec 2013 13:39:09 -0500 Subject: [PATCH] Provide an option to not verify the domain Domains are not always easily specified. With things like GitHub Enterprise and other "non-standard" domains, this parsing method will short-circuit. Therefore provide a mechanism to disable domain verification. --- giturlparse/__init__.py | 8 ++++---- giturlparse/parser.py | 9 +++++---- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/giturlparse/__init__.py b/giturlparse/__init__.py index 3c519ef..6ffca86 100644 --- a/giturlparse/__init__.py +++ b/giturlparse/__init__.py @@ -3,8 +3,8 @@ from giturlparse.result import GitUrlParsed -def parse(url): - return GitUrlParsed(_parse(url)) +def parse(url, check_domain=True): + return GitUrlParsed(_parse(url, check_domain)) -def validate(url): - return parse(url).valid +def validate(url, check_domain=True): + return parse(url, check_domain).valid diff --git a/giturlparse/parser.py b/giturlparse/parser.py index fbe83bf..810d9d0 100644 --- a/giturlparse/parser.py +++ b/giturlparse/parser.py @@ -15,7 +15,7 @@ ) -def parse(url): +def parse(url, check_domain=True): # Values are None by default parsed_info = defaultdict(lambda: None) @@ -35,9 +35,10 @@ def parse(url): # Skip if domain is bad domain = match.group('domain') #print('[%s] DOMAIN = %s' % (url, domain,)) - if platform.DOMAINS and not(domain in platform.DOMAINS): - #print("domain: %s not in %s" % (domain, platform.DOMAINS)) - continue + if check_domain: + if platform.DOMAINS and not(domain in platform.DOMAINS): + #print("domain: %s not in %s" % (domain, platform.DOMAINS)) + continue # Get matches as dictionary matches = match.groupdict()