> can we add a check here to avoid suggesting a name if original name is fine, e.g. !(/\.pdf($|[#?])/i.test(originalUrl)) ?

What's the harm in suggesting a file name if the original name already ends with `.pdf`? The outcome will not be any better. By using the check you're suggesting, `download.aspx?path=foo.pdf` would still print `download.aspx`.