@@ -98,6 +98,22 @@ async def get_pypi_data_from_purl(
9898 valid_distribution_urls .insert (0 , wheel_url )
9999
100100 urls = {url .get ("url" ): url for url in response .get ("urls" ) or []}
101+
102+ def remove_credentials_from_url (url : str ):
103+ # Parse the URL into its components
104+ parsed = urlparse (url )
105+
106+ new_netloc = parsed .hostname
107+ if parsed .port :
108+ new_netloc += f":{ parsed .port } "
109+
110+ # Create a new parsed result object, replacing the old netloc
111+ # with our new one that has no credentials.
112+ parsed = parsed ._replace (netloc = new_netloc )
113+ url_without_credentials = urlunparse (parsed )
114+
115+ return url_without_credentials
116+
101117 # iterate over the valid distribution urls and return the first
102118 # one that is matching.
103119 for dist_url in valid_distribution_urls :
@@ -111,12 +127,12 @@ async def get_pypi_data_from_purl(
111127 primary_language = "Python" ,
112128 description = get_description (info ),
113129 homepage_url = homepage_url ,
114- api_data_url = api_url ,
130+ api_data_url = remove_credentials_from_url ( api_url ) ,
115131 bug_tracking_url = bug_tracking_url ,
116132 code_view_url = code_view_url ,
117133 license_expression = info .get ("license_expression" ),
118134 declared_license = get_declared_license (info ),
119- download_url = dist_url ,
135+ download_url = remove_credentials_from_url ( dist_url ) ,
120136 size = url_data .get ("size" ),
121137 md5 = digests .get ("md5" ) or url_data .get ("md5_digest" ),
122138 sha256 = digests .get ("sha256" ),
0 commit comments