Commits

Mike Lin committed eba248d

For the s3 and s3boto backends, the 'url' methods remove trailing slashes but should not. This fixes that.

  • Participants
  • Parent commits 4294a23

Comments (0)

Files changed (2)

File storages/backends/s3.py

         return content_length and int(content_length) or 0
 
     def url(self, name):
-        name = self._clean_name(name)
+        # Preserve the trailing slash after normalizing the path.
+        trailing_slash = '/' if name and name[-1] == '/' else ''
+        name = self._clean_name(name) + trailing_slash
         if QUERYSTRING_ACTIVE:
             return self.generator.generate_url('GET', self.bucket, name)
         else:

File storages/backends/s3boto.py

         return parse_ts_extended(entry.last_modified)
 
     def url(self, name, headers=None, response_headers=None):
-        name = self._normalize_name(self._clean_name(name))
+        # Preserve the trailing slash after normalizing the path.
+        trailing_slash = '/' if name and name[-1] == '/' else ''
+        name = self._normalize_name(self._clean_name(name)) + trailing_slash
         if self.custom_domain:
             return "%s//%s/%s" % (self.url_protocol,
                                   self.custom_domain, filepath_to_uri(name))