From 0fd4a5a6f88ac32e5b4be0ef3d12122c2e90cc4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sylvain=20Frai=CC=88sse=CC=81?= Date: Tue, 24 Sep 2013 00:00:52 +0200 Subject: [PATCH] Updates a test to show the ltrip use problem --- moto/s3/utils.py | 4 ++-- tests/test_s3/test_s3_utils.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/moto/s3/utils.py b/moto/s3/utils.py index 7dd0acccc..19b0cfdf0 100644 --- a/moto/s3/utils.py +++ b/moto/s3/utils.py @@ -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.replace("www.", "") + if domain.startswith('www.'): + domain = domain[4:] if 'amazonaws.com' in domain: bucket_result = bucket_name_regex.search(domain) diff --git a/tests/test_s3/test_s3_utils.py b/tests/test_s3/test_s3_utils.py index 5b03d61fd..cb8bd8b8c 100644 --- a/tests/test_s3/test_s3_utils.py +++ b/tests/test_s3/test_s3_utils.py @@ -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():