mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-12 23:16:26 +00:00
fix(pypi): trim simple repo markup with extra whitespaces and new lines (#27013)
Co-authored-by: Rhys Arkins <rhys@arkins.net>
This commit is contained in:
parent
649fb78e48
commit
a025178e71
3 changed files with 38 additions and 1 deletions
|
@ -0,0 +1,14 @@
|
|||
<!DOCTYPE html>
|
||||
<html><head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||
<title> Links for package with extra whitespaces </title>
|
||||
</head>
|
||||
<body>
|
||||
<h1> Links for package with extra whitespaces </h1>
|
||||
<a href="">
|
||||
package_with_whitespaces-2.0.0.tar.gz
|
||||
</a><br>
|
||||
<a href=""> package_with_whitespaces-2.0.1-py3-none-any.whl </a><br>
|
||||
<a href=""> package_with_whitespaces-2.0.2-py3-none-any.whl</a><br>
|
||||
<a href="">package_with_whitespaces-2.0.2.tar.gz </a><br>
|
||||
</body></html>
|
|
@ -14,6 +14,9 @@ const dataRequiresPythonResponse = Fixtures.get(
|
|||
const mixedHyphensResponse = Fixtures.get('versions-html-mixed-hyphens.html');
|
||||
const mixedCaseResponse = Fixtures.get('versions-html-mixed-case.html');
|
||||
const withPeriodsResponse = Fixtures.get('versions-html-with-periods.html');
|
||||
const withWhitespacesResponse = Fixtures.get(
|
||||
'versions-html-with-whitespaces.html',
|
||||
);
|
||||
const hyphensResponse = Fixtures.get('versions-html-hyphens.html');
|
||||
|
||||
const baseUrl = 'https://pypi.org/pypi';
|
||||
|
@ -430,6 +433,26 @@ describe('modules/datasource/pypi/index', () => {
|
|||
]);
|
||||
});
|
||||
|
||||
it('process data from simple endpoint with extra whitespaces in html', async () => {
|
||||
httpMock
|
||||
.scope('https://some.registry.org/simple/')
|
||||
.get('/package-with-whitespaces/')
|
||||
.reply(200, withWhitespacesResponse);
|
||||
const config = {
|
||||
registryUrls: ['https://some.registry.org/simple/'],
|
||||
};
|
||||
const res = await getPkgReleases({
|
||||
datasource,
|
||||
...config,
|
||||
packageName: 'package-with-whitespaces',
|
||||
});
|
||||
expect(res?.releases).toMatchObject([
|
||||
{ version: '2.0.0' },
|
||||
{ version: '2.0.1' },
|
||||
{ version: '2.0.2' },
|
||||
]);
|
||||
});
|
||||
|
||||
it('returns null for empty response', async () => {
|
||||
httpMock
|
||||
.scope('https://some.registry.org/simple/')
|
||||
|
|
|
@ -246,7 +246,7 @@ export class PypiDatasource extends Datasource {
|
|||
const releases: Releases = {};
|
||||
for (const link of Array.from(links)) {
|
||||
const version = PypiDatasource.extractVersionFromLinkText(
|
||||
link.text,
|
||||
link.text?.trim(),
|
||||
packageName,
|
||||
);
|
||||
if (version) {
|
||||
|
|
Loading…
Reference in a new issue