Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 94fdb81

Browse files
reda-alaouicalebcartwright
authored andcommitted
Maven central service should not parse versions as number (badges#3935)
1 parent 0f68754 commit 94fdb81

2 files changed

Lines changed: 31 additions & 4 deletions

File tree

services/maven-central/maven-central.service.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@ const schema = Joi.object({
99
versioning: Joi.object({
1010
versions: Joi.object({
1111
version: Joi.array()
12-
.items(
13-
Joi.alternatives(Joi.string().required(), Joi.number().required())
14-
)
12+
.items(Joi.string().required())
1513
.single()
1614
.required(),
1715
}).required(),
@@ -71,7 +69,11 @@ module.exports = class MavenCentral extends BaseXmlService {
7169
const group = encodeURIComponent(groupId).replace(/\./g, '/')
7270
const artifact = encodeURIComponent(artifactId)
7371
const url = `https://repo1.maven.org/maven2/${group}/${artifact}/maven-metadata.xml`
74-
return this._requestXml({ schema, url })
72+
return this._requestXml({
73+
schema,
74+
url,
75+
parserOptions: { parseNodeValue: false },
76+
})
7577
}
7678

7779
async handle({ groupId, artifactId, versionPrefix }) {

services/maven-central/maven-central.tester.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,28 @@ t.create('inexistent artifact')
2626
t.create('inexistent version prefix')
2727
.get('/com.github.fabriziocucci/yacl4j/99.json')
2828
.expectBadge({ label: 'maven-central', message: 'version prefix not found' })
29+
30+
t.create('version ending with zero')
31+
.get('/mocked-group-id/mocked-artifact-id.json')
32+
.intercept(nock =>
33+
nock('https://repo1.maven.org/maven2')
34+
.get('/mocked-group-id/mocked-artifact-id/maven-metadata.xml')
35+
.reply(
36+
200,
37+
`
38+
<metadata>
39+
<groupId>mocked-group-id</groupId>
40+
<artifactId>mocked-artifact-id</artifactId>
41+
<versioning>
42+
<latest>1.30</latest>
43+
<release>1.30</release>
44+
<versions>
45+
<version>1.30</version>
46+
</versions>
47+
<lastUpdated>20190902002617</lastUpdated>
48+
</versioning>
49+
</metadata>
50+
`
51+
)
52+
)
53+
.expectBadge({ label: 'maven-central', message: /^v1\.30$/ })

0 commit comments

Comments
 (0)