Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(pypi): ensure trailing slash for simple API endpoints #8879

Merged
merged 1 commit into from
Feb 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 8 additions & 8 deletions lib/datasource/pypi/__snapshots__/index.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Array [
"user-agent": "https://github.com/renovatebot/renovate",
},
"method": "GET",
"url": "https://custom.pypi.net/foo/dj-database-url",
"url": "https://custom.pypi.net/foo/dj-database-url/",
},
]
`;
Expand Down Expand Up @@ -114,7 +114,7 @@ Array [
"user-agent": "https://github.com/renovatebot/renovate",
},
"method": "GET",
"url": "https://pypi.org/simple/dj-database-url",
"url": "https://pypi.org/simple/dj-database-url/",
},
]
`;
Expand Down Expand Up @@ -169,7 +169,7 @@ Array [
"user-agent": "https://github.com/renovatebot/renovate",
},
"method": "GET",
"url": "https://some.registry.org/+simple/dj-database-url",
"url": "https://some.registry.org/+simple/dj-database-url/",
},
]
`;
Expand Down Expand Up @@ -224,7 +224,7 @@ Array [
"user-agent": "https://github.com/renovatebot/renovate",
},
"method": "GET",
"url": "https://pypi.org/simple/dj-database-url",
"url": "https://pypi.org/simple/dj-database-url/",
},
]
`;
Expand All @@ -248,7 +248,7 @@ Array [
"user-agent": "https://github.com/renovatebot/renovate",
},
"method": "GET",
"url": "https://pypi.org/simple/image-collector",
"url": "https://pypi.org/simple/image-collector/",
},
]
`;
Expand Down Expand Up @@ -435,7 +435,7 @@ Array [
"user-agent": "https://github.com/renovatebot/renovate",
},
"method": "GET",
"url": "https://pypi.org/pypi/something",
"url": "https://pypi.org/pypi/something/",
},
]
`;
Expand All @@ -449,7 +449,7 @@ Array [
"user-agent": "https://github.com/renovatebot/renovate",
},
"method": "GET",
"url": "https://pypi.org/simple/dj-database-url",
"url": "https://pypi.org/simple/dj-database-url/",
},
]
`;
Expand All @@ -463,7 +463,7 @@ Array [
"user-agent": "https://github.com/renovatebot/renovate",
},
"method": "GET",
"url": "https://pypi.org/simple/dj-database-url",
"url": "https://pypi.org/simple/dj-database-url/",
},
]
`;
Expand Down
20 changes: 10 additions & 10 deletions lib/datasource/pypi/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ describe('datasource/pypi', () => {
});
it('returns null for 404', async () => {
httpMock.scope(baseUrl).get('/something/json').reply(404);
httpMock.scope(baseUrl).get('/something').reply(404);
httpMock.scope(baseUrl).get('/something/').reply(404);
expect(
await getPkgReleases({
datasource,
Expand Down Expand Up @@ -233,7 +233,7 @@ describe('datasource/pypi', () => {
it('process data from simple endpoint', async () => {
httpMock
.scope('https://pypi.org/simple/')
.get('/dj-database-url')
.get('/dj-database-url/')
.reply(200, htmlResponse);
const config = {
registryUrls: ['https://pypi.org/simple/'],
Expand All @@ -251,7 +251,7 @@ describe('datasource/pypi', () => {
it('process data from +simple endpoint', async () => {
httpMock
.scope('https://some.registry.org/+simple/')
.get('/dj-database-url')
.get('/dj-database-url/')
.reply(200, htmlResponse);
const config = {
registryUrls: ['https://some.registry.org/+simple/'],
Expand All @@ -270,7 +270,7 @@ describe('datasource/pypi', () => {
hostRules.add({ hostName: 'some.private.registry.org', token: 'abc123' });
httpMock
.scope('https://some.private.registry.org/+simple/')
.get('/dj-database-url')
.get('/dj-database-url/')
.reply(200, htmlResponse);
const config = {
registryUrls: ['https://some.private.registry.org/+simple/'],
Expand All @@ -286,7 +286,7 @@ describe('datasource/pypi', () => {
it('process data from simple endpoint with hyphens replaced with underscores', async () => {
httpMock
.scope('https://pypi.org/simple/')
.get('/image-collector')
.get('/image-collector/')
.reply(200, mixedHyphensResponse);
const config = {
registryUrls: ['https://pypi.org/simple/'],
Expand All @@ -304,7 +304,7 @@ describe('datasource/pypi', () => {
it('returns null for empty response', async () => {
httpMock
.scope('https://pypi.org/simple/')
.get('/dj-database-url')
.get('/dj-database-url/')
.reply(200);
const config = {
registryUrls: ['https://pypi.org/simple/'],
Expand All @@ -322,7 +322,7 @@ describe('datasource/pypi', () => {
it('returns null for 404 response from simple endpoint', async () => {
httpMock
.scope('https://pypi.org/simple/')
.get('/dj-database-url')
.get('/dj-database-url/')
.replyWithError('error');
const config = {
registryUrls: ['https://pypi.org/simple/'],
Expand All @@ -340,7 +340,7 @@ describe('datasource/pypi', () => {
it('returns null for response with no versions', async () => {
httpMock
.scope('https://pypi.org/simple/')
.get('/dj-database-url')
.get('/dj-database-url/')
.reply(200, badResponse);
const config = {
registryUrls: ['https://pypi.org/simple/'],
Expand All @@ -361,7 +361,7 @@ describe('datasource/pypi', () => {
.reply(404);
httpMock
.scope('https://custom.pypi.net/foo')
.get('/dj-database-url')
.get('/dj-database-url/')
.reply(200, htmlResponse);
const config = {
registryUrls: ['https://custom.pypi.net/foo'],
Expand All @@ -377,7 +377,7 @@ describe('datasource/pypi', () => {
it('parses data-requires-python and respects constraints from simple endpoint', async () => {
httpMock
.scope('https://pypi.org/simple/')
.get('/dj-database-url')
.get('/dj-database-url/')
.reply(200, dataRequiresPythonResponse);
const config = {
registryUrls: ['https://pypi.org/simple/'],
Expand Down
2 changes: 1 addition & 1 deletion lib/datasource/pypi/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ async function getSimpleDependency(
packageName: string,
hostUrl: string
): Promise<ReleaseResult | null> {
const lookupUrl = url.resolve(hostUrl, `${packageName}`);
const lookupUrl = url.resolve(hostUrl, ensureTrailingSlash(packageName));
const dependency: ReleaseResult = { releases: null };
const response = await http.get(lookupUrl);
const dep = response?.body;
Expand Down