Skip to content

Commit

Permalink
Fix a small bug in "host extraction from url" part in python module.
Browse files Browse the repository at this point in the history
  • Loading branch information
manugarg committed Jan 21, 2008
1 parent 8bf5213 commit 7b1d7ff
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions pymod/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,15 @@ def find_proxy(url, host=None):
defined, it's extracted from url.
"""
if host is None:
matches = url_regex.findall(url)[0]
if len(matches) is not 2:
m = url_regex.match(url)
if not m:
print 'URL: %s is not a valid URL' % url
return None
if len(m.groups()) is 2:
host = m.groups()[1]
else:
print 'URL: %s is not a valid URL' % url
return None
host = matches[1]
return _pacparser.find_proxy(url, host)

def cleanup():
Expand All @@ -77,11 +81,15 @@ def just_find_proxy(pacfile, url, host=None):
print 'PAC file: %s doesn\'t exist' % pacfile
return None
if host is None:
matches = url_regex.findall(url)[0]
if len(matches) is not 2:
m = url_regex.match(url)
if not m:
print 'URL: %s is not a valid URL' % url
return None
if len(m.groups()) is 2:
host = m.groups()[1]
else:
print 'URL: %s is not a valid URL' % url
return None
host = matches[1]
init()
parse_pac(pacfile)
proxy = find_proxy(url,host)
Expand Down

0 comments on commit 7b1d7ff

Please sign in to comment.