Skip to content

Commit

Permalink
Merge pull request #101 from clearlydefined/roman/tool_version_fix
Browse files Browse the repository at this point in the history
Fix tools version detection for coordinates with %252f characters
  • Loading branch information
qtomlinson authored Oct 17, 2024
2 parents 15aec70 + a307e4b commit 41eebfc
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion tools/integration/lib/harvestResultFetcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class HarvestResultFetcher {
return tools.flatMap(tool => {
const found = harvestResultUrls
.filter(url => url.includes(`/${tool}/`))
.map(url => url.substring(`${this._coordinates}/${tool}/`.length))
.map(url => url.match(/[^/]+$/)[0])
.map(version => [tool, version])
return found.length ? found : [[tool, '']]
})
Expand Down
22 changes: 22 additions & 0 deletions tools/integration/test/lib/harvesterResultFetcherTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,28 @@ describe('HarvestResultFetcher', function () {
])
})

it('should process the result for coordinates containing double-encoded slash', async function () {
const coordinates = 'go/golang/github.com%252fogen-go/ogen/v0.0.0-20211007041714-5bab77a84e75'
fetchStub = sinon.stub()
resultMonitor = new HarvestResultFetcher(apiBaseUrl, coordinates, fetchStub)

const harvestResults = [
'go/golang/github.com%2fogen-go/ogen/v0.0.0-20211007041714-5bab77a84e75/clearlydefined/1.3.1',
'go/golang/github.com%2fogen-go/ogen/v0.0.0-20211007041714-5bab77a84e75/licensee/9.14.0',
'go/golang/github.com%2fogen-go/ogen/v0.0.0-20211007041714-5bab77a84e75/reuse/3.2.1',
'go/golang/github.com%2fogen-go/ogen/v0.0.0-20211007041714-5bab77a84e75/reuse/3.2.2',
'go/golang/github.com%2fogen-go/ogen/v0.0.0-20211007041714-5bab77a84e75/scancode/30.3.0'
]
fetchStub.resolves(new Response(JSON.stringify(harvestResults)))
const toolVersions = await resultMonitor.fetchToolVersions()
deepStrictEqual(toolVersions, [
['licensee', '9.14.0'],
['reuse', '3.2.1'],
['reuse', '3.2.2'],
['scancode', '30.3.0']
])
})

it('should handle no result for tools', async function () {
const harvestResults = []
fetchStub.resolves(new Response(JSON.stringify(harvestResults)))
Expand Down

0 comments on commit 41eebfc

Please sign in to comment.