Skip to content

Commit 4ca8e8f

Browse files
Ensure package_urls end with a slash
In PyPI simple repository format, package URLs typically end with the package name and should have a trailing slash [1]. To ensure this trailing slash, the some web servers might redirect to the URL with the trailing slash. This causes the issue that the BasicAuth credentials are removed from the request for security reasons. This was observed with an internal Artifactory repository and adding a trailing slash to the package_url fixes the issue. [1]: https://peps.python.org/pep-0503/#specification Resolves: #127. Signed-off-by: Marcel Bochtler <[email protected]>
1 parent f634e2d commit 4ca8e8f

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/python_inspector/utils_pypi.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1598,6 +1598,10 @@ async def fetch_links(
15981598
name using the `index_url` of this repository.
15991599
"""
16001600
package_url = f"{self.index_url}/{normalized_name}"
1601+
1602+
if not package_url.endswith('/'):
1603+
package_url += '/'
1604+
16011605
text, _ = await CACHE.get(
16021606
path_or_url=package_url,
16031607
credentials=self.credentials,

0 commit comments

Comments
 (0)