Skip to content

Commit 3ec2ff6

Browse files
committed
fixed url filename parsing
1 parent 823111e commit 3ec2ff6

3 files changed

Lines changed: 7 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1414
- Added tests for this new behavior.
1515

1616
### Changed
17-
- slight change to raise a file not downloaded error if `tind_download()` fails to return a written file path.
17+
- Raises a file not downloaded error if `tind_download()` fails to return a written file path.
18+
19+
### Fixed
20+
- Found a bug in the `fetch_file()` method where the "backup" filename parsing logic would always return
21+
`download` as the filename.
1822

1923

2024
## [0.2.4]

tind_client/api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def tind_download(url: str, output_dir: str, api_key: str) -> Tuple[int, str]:
8787
return status, ""
8888

8989
# Fall-back to the file name in the URL if it isn't included in the response.
90-
output_filename = url.rstrip("/").split("/")[-2]
90+
output_filename = url.split("?")[0].rstrip("/").split("/")[-2]
9191

9292
# See if we can extract the filename from the response headers.
9393
if "Content-Disposition" in resp.headers:

tind_client/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def fetch_file(
9595

9696
output_target = output_dir or self.default_storage_dir
9797

98-
expected_filename = file_url.rstrip("/").split("/")[-2]
98+
expected_filename = file_url.split("?")[0].rstrip("/").split("/")[-2]
9999
expected_path = Path(output_target) / expected_filename
100100

101101
if meta_mtime and expected_path.exists():

0 commit comments

Comments
 (0)