From 1b6d8c9e0df389baf6454dd216c86d71a93ecb71 Mon Sep 17 00:00:00 2001
From: TheTechromancer <thetechromancer@protonmail.com>
Date: Thu, 21 Sep 2023 16:02:41 -0400
Subject: [PATCH] fix filename with root url path

---
 bbot/modules/filedownload.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/bbot/modules/filedownload.py b/bbot/modules/filedownload.py
index a9c56bbcf..8b61dbdd8 100644
--- a/bbot/modules/filedownload.py
+++ b/bbot/modules/filedownload.py
@@ -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
@@ -136,8 +135,6 @@ 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:
@@ -145,6 +142,9 @@ def make_filename(self, url, content_type=None):
         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: