More about this vulnerability button don't work
dzienisz opened this issue · 5 comments
dzienisz commented
nprail commented
Oh, looks like that field can be a comma-separated list of URLs. Should be fairly easy to resolve.
dzienisz commented
I can fix it as #hacktoberfest issue
dzienisz commented
@nprail can you help me?
I see that we render this list by using {{#if references}}
but it sometimes return markdown data and sometimes urls separated by comma 🤯
I can't find in code where {{references}}
is created.
nprail commented
@dzienisz references
comes from directly from npm audit --json
without manipulation. We will probably have to loop through the advisories and parse that field somehow into a consistent format.
Here is a possible algorithm to determine if it is a comma separated list of URLs:
const splitList = advisory.references.split(',')
let isUrlList = true
for (const urlItem of splitList) {
try {
new URL(urlItem)
} catch (err) {
// if new URL throws an error, than the item isn't a valid URL
isUrlList = false
}
}
// if any of the items do not parse as a URL then it probably isn't a comma-separated list of URLs
return isUrlList