Merge pull request #14 from NoahSaso/noah-clean-file-ext

Clean up encoded query params from file extension
This commit is contained in:
Leonardo Cavaletti 2020-10-27 20:19:34 +00:00 committed by GitHub
commit 37af2da9ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -183,6 +183,8 @@ class Parser:
content_type = response.headers.get("content-type")
if content_type:
file_extension = mimetypes.guess_extension(content_type)
elif '%3f' in file_extension.lower():
file_extension = re.split("%3f", file_extension, flags=re.IGNORECASE)[0]
destination = destination.with_suffix(file_extension)
Path(destination).parent.mkdir(parents=True, exist_ok=True)