Extract _get_url_preserving_filename() (not nice).