Skip to content

Commit 1ed1728

Browse files
committed
use inputPurl for simpler more robust mapping
1 parent 0fab7bf commit 1ed1728

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

src/ui/purl-alerts-and-scores/manager.ts

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export type PackageScoreAndAlerts = {
2222
severity: 'critical' | 'high' | 'medium' | 'low',
2323
props: any
2424
}>,
25+
inputPurl: SimPURL,
2526
score: {
2627
license: number,
2728
maintenance: number,
@@ -202,16 +203,9 @@ export class PURLDataCache {
202203
})
203204
for await (const line of lines) {
204205
const scoreAndAlerts = JSON.parse(line) as PackageScoreAndAlerts
205-
const type = scoreAndAlerts.type
206-
const name = type === 'pypi' ? scoreAndAlerts.name.replaceAll('-', '_') : scoreAndAlerts.name
207-
const namespace = scoreAndAlerts.namespace ? scoreAndAlerts.namespace + '/' : '';
208-
const purlWithoutVersion = `pkg:${type}/${namespace}${name}${scoreAndAlerts.qualifiers ? '?' + scoreAndAlerts.qualifiers : ''}${scoreAndAlerts.subpath ? '#' + scoreAndAlerts.subpath : ''}` as SimPURL;
209-
const purlWithVersion = `pkg:${type}/${namespace}${name}@${scoreAndAlerts.version}${scoreAndAlerts.qualifiers ? '?' + scoreAndAlerts.qualifiers : ''}${scoreAndAlerts.subpath ? '#' + scoreAndAlerts.subpath : ''}` as SimPURL;
210-
this.#pkgData.get(purlWithoutVersion)?.update(scoreAndAlerts);
211-
this.#pkgData.get(purlWithVersion)?.update(scoreAndAlerts);
212-
213-
thesePendingUpdates.delete(purlWithoutVersion)
214-
thesePendingUpdates.delete(purlWithVersion);
206+
const inputPurl = scoreAndAlerts.inputPurl
207+
this.#pkgData.get(inputPurl)?.update(scoreAndAlerts);
208+
thesePendingUpdates.delete(inputPurl)
215209
}
216210
bailPendingCacheEntries(new Error('Not Found'))
217211
} catch (e) {

0 commit comments

Comments
 (0)