Skip to content

Commit

Permalink
fix filename with root url path
Browse files Browse the repository at this point in the history
  • Loading branch information
TheTechromancer committed Sep 21, 2023
1 parent e5963f3 commit 1b6d8c9
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions bbot/modules/filedownload.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ class filedownload(BaseModule):
"indd", # Adobe InDesign Document
"ini", # Initialization File
"jar", # Java Archive
"json", # JavaScript Object Notation File
"key", # Private Key File
"pub", # Public Key File
"log", # Log File
Expand Down Expand Up @@ -136,15 +135,16 @@ def make_filename(self, url, content_type=None):
parsed_url = self.helpers.urlparse(url)
base_url = f"{parsed_url.scheme}://{parsed_url.netloc}"
url_path = parsed_url.path.strip("/")
if not url_path:
url_path = "unknown"
# try to get extension from URL path
extension = Path(url_path).suffix.strip(".").lower()
if extension:
url_stem = url.rsplit(".", 1)[0]
else:
url_stem = str(url)
filename = f"{self.helpers.make_date()}_{self.helpers.tagify(url_stem)}"
if not url_path:
url_path = "unknown"
filename = f"{filename}-{url_path}"
# if that fails, try to get it from content type
if not extension:
if content_type and content_type in self.mime_db:
Expand Down

0 comments on commit 1b6d8c9

Please sign in to comment.