Merge pull request #45 from fraisse/fix/domain_www_strip_error

Fix the 'www.' strip changing the lstrip method by the replace
This commit is contained in:
Steve Pulec 2013-09-24 16:30:44 -07:00
commit 20a34a1be2
2 changed files with 3 additions and 3 deletions

View File

@ -8,8 +8,8 @@ bucket_name_regex = re.compile("(.+).s3.amazonaws.com")
def bucket_name_from_url(url):
domain = urlparse.urlparse(url).netloc
# If 'www' prefixed, strip it.
domain = domain.lstrip("www.")
if domain.startswith('www.'):
domain = domain[4:]
if 'amazonaws.com' in domain:
bucket_result = bucket_name_regex.search(domain)

View File

@ -7,7 +7,7 @@ def test_base_url():
def test_localhost_bucket():
expect(bucket_name_from_url('https://foobar.localhost:5000/abc')).should.equal("foobar")
expect(bucket_name_from_url('https://wfoobar.localhost:5000/abc')).should.equal("wfoobar")
def test_localhost_without_bucket():