Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Use page title for filename with :download #2753
I think this method is a bit too simplistic, as it always takes the page title, even for non-HTML pages:
(the old method produced a
I think the question is: How do we determine if we got a sensible filename out of the URL, or when should we use the page title?
Hmm, damn. This is indeed something I didn't consider, and a good point...
I have two ideas:
I'd probably add "if there's no extension", as many modern pages don't even use extensions anymore (for example, GitHub:
Alternatively, we could put this behind a flag (
This is getting a bit more complex than I thought originally (sorry!)
I suggest moving it into a
def suggested_fn_from_title(url, title): (or so) function in
Could you please also add an unittest in
tests/unit/browser/webkit/test_downloads.py for all those special cases? This can probably benefit from pytest's parametrization, see e.g.
tests/unit/utils/test_utils.py for a simple example.