Skip to content

Commit

Permalink
fix(LicensesReport): proper fallback if no URL is defined for a package
Browse files Browse the repository at this point in the history
Some npm packages in the wild, such as `reading-time`, do not define a
repository or homepage, or do not do so properly.

To avoid generating invalid anchor elements in such cases with no href
attribute, let's fall back to displaying a "-" text node in such cases,
as it's already done with the authors column.
  • Loading branch information
AlexTMjugador committed Feb 14, 2023
1 parent f145588 commit 1e6479b
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions components/LicensesReport/LicensesReport.astro
Expand Up @@ -131,14 +131,17 @@ const report = cache[uniqueKey];
</div>

<div class:list={['td', props.class]} role="cell">
<a
class:list="[is-external]"
href={row.homepage || row.repository.url}
target="_blank"
rel="noopener nofollow"
>
{row.homepage || row.repository.url}
</a>
{row.homepage || row.repository.url
? <a
class:list="[is-external]"
href={row.homepage || row.repository.url}
target="_blank"
rel="noopener nofollow"
>
{row.homepage || row.repository.url}
</a>
: '-'
}
</div>
</div>
))
Expand Down

0 comments on commit 1e6479b

Please sign in to comment.