Skip to content

Commit

Permalink
Update pypi base url
Browse files Browse the repository at this point in the history
Based on docs at https://packaging.python.org/en/latest/guides/migrating-to-pypi-org/, "the default interface for browsing packages is pypi.org. The domain pypi.python.org now redirects to pypi.org, and may be disabled sometime in the future."

Also see pypi json api documentation at https://docs.pypi.org/api/json/

Update the urls for the pypi json api in originPypi and pypiCoordinatesMapper to reflect this.
  • Loading branch information
qtomlinson committed Jan 17, 2025
1 parent ef000e6 commit b577ba1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions lib/pypiCoordinatesMapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const EntityCoordinates = require('./entityCoordinates')

class PypiCoordinatesMapper {
constructor(fetch = requestPromise) {
this.baseUrl = 'https://pypi.python.org'
this.baseUrl = 'https://pypi.org'
this._fetch = fetch
}

Expand All @@ -23,7 +23,8 @@ class PypiCoordinatesMapper {

async _resolve(coordinates) {
if (coordinates.name === '..') return null
const url = new URL(`/pypi/${coordinates.name}/json`, this.baseUrl).toString()
const encodedName = encodeURIComponent(coordinates.name)
const url = new URL(`/pypi/${encodedName}/json`, this.baseUrl).toString()
try {
const answer = await this._fetch({ url, method: 'GET', json: true })
return answer?.info?.name && { name: answer.info.name }
Expand Down
2 changes: 1 addition & 1 deletion routes/originPyPi.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ router.get(
})
)
async function getPypiData(name) {
const url = `https://pypi.python.org/pypi/${encodeURIComponent(name)}/json`
const url = `https://pypi.org/pypi/${encodeURIComponent(name)}/json`
try {
return await requestPromise({ url, method: 'GET', json: true })
} catch (error) {
Expand Down

0 comments on commit b577ba1

Please sign in to comment.