diff --git a/CHANGELOG.md b/CHANGELOG.md index 86403b0..8140467 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased +### Fixed + +- Fix a bug that prevented non-standard relative urls to be treated as such + (the ones that starts with `../` or `./`) + [#174](https://github.com/pyodide/micropip/pull/174) + ## [0.8.0] - 2024/12/15 ### Added diff --git a/micropip/package_index.py b/micropip/package_index.py index 49974b7..562a252 100644 --- a/micropip/package_index.py +++ b/micropip/package_index.py @@ -7,7 +7,7 @@ from dataclasses import dataclass from functools import partial from typing import Any -from urllib.parse import urlparse, urlunparse +from urllib.parse import urljoin, urlparse, urlunparse from packaging.utils import InvalidWheelFilename from packaging.version import InvalidVersion, Version @@ -130,8 +130,10 @@ def _parse_pep691_response( version = parse_version(filename) except (InvalidVersion, InvalidWheelFilename): continue - if file["url"].startswith("/"): - file["url"] = index_base_url + file["url"] + + is_absolute_url = bool(urlparse(file["url"]).netloc) + if not is_absolute_url: + file["url"] = urljoin(index_base_url, file["url"]) releases[version].append(file) diff --git a/tests/test_data/pypi_response/relative-urls-test_simple.html b/tests/test_data/pypi_response/relative-urls-test_simple.html new file mode 100644 index 0000000..7f5e83d --- /dev/null +++ b/tests/test_data/pypi_response/relative-urls-test_simple.html @@ -0,0 +1,17 @@ + + +
+ +