Fix parsing of clean_url (#31783)

In #31618 the idea was to determine the file extension heuristically by dropping query params etc from a url and then consider it as a file path. That broke for URLs that only have query params like http://example.com/?patch=x as it would result in empty string as basename. This PR reverts to the old behavior of saving files as ?patch=x in that case.

Co-authored-by: Stephen Sachs <stesachs@amazon.com>
This commit is contained in:
Stephen Sachs 2022-07-28 11:24:19 +02:00 committed by GitHub
parent 2dd4795f56
commit 584cc47fb3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -366,9 +366,9 @@ def expected_archive_files(self):
fnames = [] fnames = []
expanded = True expanded = True
if isinstance(self.default_fetcher, fs.URLFetchStrategy): if isinstance(self.default_fetcher, fs.URLFetchStrategy):
url_path = url_util.parse(self.default_fetcher.url).path
expanded = self.default_fetcher.expand_archive expanded = self.default_fetcher.expand_archive
clean_url = os.path.basename(sup.sanitize_file_path(url_path)) clean_url = os.path.basename(
sup.sanitize_file_path(self.default_fetcher.url))
fnames.append(clean_url) fnames.append(clean_url)
if self.mirror_paths: if self.mirror_paths: