From c9fd182dba0e922550873a13c7db825dfee774b7 Mon Sep 17 00:00:00 2001 From: Iordanis Grigoriou Date: Sat, 8 Jul 2017 16:28:58 +0200 Subject: [PATCH] Adjust suggested_fn_from_title, add tests --- qutebrowser/browser/downloads.py | 4 ++-- tests/unit/browser/webkit/test_downloads.py | 12 +++++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/qutebrowser/browser/downloads.py b/qutebrowser/browser/downloads.py index e9499600e..438dfc528 100644 --- a/qutebrowser/browser/downloads.py +++ b/qutebrowser/browser/downloads.py @@ -197,8 +197,8 @@ def suggested_fn_from_title(url_path, title=None): _, ext = os.path.splitext(url_path) if ext.lower() in ext_whitelist and title: suggested_fn = utils.sanitize_filename(title) - if not suggested_fn.lower().endswith(ext.lower()): - suggested_fn += ext + if not suggested_fn.lower().endswith((".html", ".htm")): + suggested_fn += ".html" else: suggested_fn = None return suggested_fn diff --git a/tests/unit/browser/webkit/test_downloads.py b/tests/unit/browser/webkit/test_downloads.py index c9451b949..5a214f638 100644 --- a/tests/unit/browser/webkit/test_downloads.py +++ b/tests/unit/browser/webkit/test_downloads.py @@ -39,16 +39,22 @@ def test_download_model(qapp, qtmodeltester, config_stub, cookiejar_and_cache): 'Installing qutebrowser _ qutebrowser.html'), ('http://qutebrowser.org/INSTALL.HTML', 'Installing qutebrowser | qutebrowser', - 'Installing qutebrowser _ qutebrowser.HTML'), + 'Installing qutebrowser _ qutebrowser.html'), ('http://qutebrowser.org/INSTALL.html', 'Installing qutebrowser | qutebrowser.HTML', 'Installing qutebrowser _ qutebrowser.HTML'), ('http://qutebrowser.org/', 'qutebrowser | qutebrowser', - 'qutebrowser _ qutebrowser'), + 'qutebrowser _ qutebrowser.html'), ('https://github.com/qutebrowser/qutebrowser/releases', 'Releases · qutebrowser/qutebrowser', - 'Releases · qutebrowser_qutebrowser'), + 'Releases · qutebrowser_qutebrowser.html'), + ('http://qutebrowser.org/index.php', + 'qutebrowser | qutebrowser', + 'qutebrowser _ qutebrowser.html'), + ('http://qutebrowser.org/index.php', + 'qutebrowser | qutebrowser - index.php', + 'qutebrowser _ qutebrowser - index.php.html'), ('https://qutebrowser.org/img/cheatsheet-big.png', 'cheatsheet-big.png (3342×2060)', None),