From b8a41c56058f1ac4f6ba4738e9d412f612b5dd23 Mon Sep 17 00:00:00 2001 From: Waldemar Hummer Date: Sat, 8 Apr 2017 15:28:51 +1000 Subject: [PATCH] fix domain handling for local domain names in S3 API --- moto/s3/responses.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/moto/s3/responses.py b/moto/s3/responses.py index 449fed0a9..59cd9d322 100644 --- a/moto/s3/responses.py +++ b/moto/s3/responses.py @@ -53,8 +53,8 @@ class ResponseObject(_TemplateEnvironmentMixin): if not host: host = urlparse(request.url).netloc - if not host or host.startswith("localhost"): - # For localhost, default to path-based buckets + if not host or host.startswith("localhost") or re.match(r"^[^.]+$", host): + # For localhost or local domain names, default to path-based buckets return False match = re.match(r'^([^\[\]:]+)(:\d+)?$', host)