Skip to content

Commit 3873134

Browse files
authored
Merge pull request #81 from KuSh/keep-gz-file-ext
fix: keep filename ext if present in case of gz files
2 parents 98994ef + 4011b60 commit 3873134

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

openaddr/cache.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,12 @@ def guess_url_file_extension(url):
153153
mimetypes.add_type('application/vnd.geo+json', '.json', False)
154154

155155
_, likely_ext = os.path.splitext(path)
156-
bad_extensions = '', '.cgi', '.php', '.aspx', '.asp', '.do'
156+
if likely_ext == '.gz':
157+
_, compressed_ext = os.path.splitext(path[:-3])
158+
if compressed_ext:
159+
likely_ext = compressed_ext + likely_ext
160+
161+
bad_extensions = "", ".cgi", ".php", ".aspx", ".asp", ".do"
157162

158163
if not query and likely_ext not in bad_extensions:
159164
#

0 commit comments

Comments
 (0)