Skip to content

Commit bd61bb8

Browse files
committed
Fallback to non-verified URLs only when a package analysis was not completed.
1 parent dd13f9e commit bd61bb8

29 files changed

+21
-136
lines changed

app/lib/package/models.dart

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1131,28 +1131,33 @@ class PackagePageData {
11311131
bool get isLatestStable => version.version == package.latestVersion;
11321132

11331133
late final packageLinks = () {
1134-
// start with the URLs from pubspec.yaml
1134+
// If the repository failed the verification tests, we are not displaying
1135+
// any links.
1136+
final result = scoreCard.panaReport?.result;
1137+
final repositoryStatus = result?.repositoryStatus;
1138+
if (repositoryStatus == RepositoryStatus.failed) {
1139+
return PackageLinks._();
1140+
}
1141+
1142+
// If the analysis completed, return the URLs from it.
1143+
if (result != null) {
1144+
return PackageLinks._(
1145+
homepageUrl: result.homepageUrl,
1146+
repositoryUrl: result.repositoryUrl,
1147+
issueTrackerUrl: result.issueTrackerUrl,
1148+
documentationUrl: result.documentationUrl,
1149+
contributingUrl: result.contributingUrl,
1150+
);
1151+
}
1152+
1153+
// Fallback: if the analysis did not complete yet, display inferred URLs from pubspec.yaml
11351154
final pubspec = version.pubspec!;
1136-
final inferred = PackageLinks.infer(
1155+
return PackageLinks.infer(
11371156
homepageUrl: pubspec.homepage,
11381157
documentationUrl: pubspec.documentation,
11391158
repositoryUrl: pubspec.repository,
11401159
issueTrackerUrl: pubspec.issueTracker,
11411160
);
1142-
1143-
// Use verified URLs when they are available.
1144-
final result = scoreCard.panaReport?.result;
1145-
if (result == null) {
1146-
return inferred;
1147-
}
1148-
1149-
return PackageLinks._(
1150-
homepageUrl: result.homepageUrl ?? inferred.homepageUrl,
1151-
repositoryUrl: result.repositoryUrl ?? inferred.repositoryUrl,
1152-
issueTrackerUrl: result.issueTrackerUrl ?? inferred.issueTrackerUrl,
1153-
documentationUrl: result.documentationUrl ?? inferred.documentationUrl,
1154-
contributingUrl: result.contributingUrl ?? inferred.contributingUrl,
1155-
);
11561161
}();
11571162

11581163
/// The URL resolver using a verified repository

app/test/frontend/golden/pkg_activity_log_page.html

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -391,8 +391,6 @@ <h3 class="title pkg-infobox-metadata">Metadata</h3>
391391
<br/>
392392
<a class="link" href="https://github.com/example/oxygen" rel="ugc">Repository (GitHub)</a>
393393
<br/>
394-
<a class="link" href="https://github.com/example/oxygen/issues" rel="ugc">View/report issues</a>
395-
<br/>
396394
<a class="link" href="https://github.com/example/oxygen/blob/master/CONTRIBUTING.md" rel="ugc">Contributing</a>
397395
<br/>
398396
</p>
@@ -469,8 +467,6 @@ <h3 class="title pkg-infobox-metadata">Metadata</h3>
469467
<br/>
470468
<a class="link" href="https://github.com/example/oxygen" rel="ugc">Repository (GitHub)</a>
471469
<br/>
472-
<a class="link" href="https://github.com/example/oxygen/issues" rel="ugc">View/report issues</a>
473-
<br/>
474470
<a class="link" href="https://github.com/example/oxygen/blob/master/CONTRIBUTING.md" rel="ugc">Contributing</a>
475471
<br/>
476472
</p>

app/test/frontend/golden/pkg_admin_page.html

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -676,8 +676,6 @@ <h3 class="title pkg-infobox-metadata">Metadata</h3>
676676
<br/>
677677
<a class="link" href="https://github.com/example/oxygen" rel="ugc">Repository (GitHub)</a>
678678
<br/>
679-
<a class="link" href="https://github.com/example/oxygen/issues" rel="ugc">View/report issues</a>
680-
<br/>
681679
<a class="link" href="https://github.com/example/oxygen/blob/master/CONTRIBUTING.md" rel="ugc">Contributing</a>
682680
<br/>
683681
</p>
@@ -754,8 +752,6 @@ <h3 class="title pkg-infobox-metadata">Metadata</h3>
754752
<br/>
755753
<a class="link" href="https://github.com/example/oxygen" rel="ugc">Repository (GitHub)</a>
756754
<br/>
757-
<a class="link" href="https://github.com/example/oxygen/issues" rel="ugc">View/report issues</a>
758-
<br/>
759755
<a class="link" href="https://github.com/example/oxygen/blob/master/CONTRIBUTING.md" rel="ugc">Contributing</a>
760756
<br/>
761757
</p>

app/test/frontend/golden/pkg_changelog_page.html

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -261,8 +261,6 @@ <h3 class="title pkg-infobox-metadata">Metadata</h3>
261261
<br/>
262262
<a class="link" href="https://github.com/example/oxygen" rel="ugc">Repository (GitHub)</a>
263263
<br/>
264-
<a class="link" href="https://github.com/example/oxygen/issues" rel="ugc">View/report issues</a>
265-
<br/>
266264
<a class="link" href="https://github.com/example/oxygen/blob/master/CONTRIBUTING.md" rel="ugc">Contributing</a>
267265
<br/>
268266
</p>
@@ -340,8 +338,6 @@ <h3 class="title pkg-infobox-metadata">Metadata</h3>
340338
<br/>
341339
<a class="link" href="https://github.com/example/oxygen" rel="ugc">Repository (GitHub)</a>
342340
<br/>
343-
<a class="link" href="https://github.com/example/oxygen/issues" rel="ugc">View/report issues</a>
344-
<br/>
345341
<a class="link" href="https://github.com/example/oxygen/blob/master/CONTRIBUTING.md" rel="ugc">Contributing</a>
346342
<br/>
347343
</p>

app/test/frontend/golden/pkg_example_page.html

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -258,8 +258,6 @@ <h3 class="title pkg-infobox-metadata">Metadata</h3>
258258
<br/>
259259
<a class="link" href="https://github.com/example/oxygen" rel="ugc">Repository (GitHub)</a>
260260
<br/>
261-
<a class="link" href="https://github.com/example/oxygen/issues" rel="ugc">View/report issues</a>
262-
<br/>
263261
<a class="link" href="https://github.com/example/oxygen/blob/master/CONTRIBUTING.md" rel="ugc">Contributing</a>
264262
<br/>
265263
</p>
@@ -337,8 +335,6 @@ <h3 class="title pkg-infobox-metadata">Metadata</h3>
337335
<br/>
338336
<a class="link" href="https://github.com/example/oxygen" rel="ugc">Repository (GitHub)</a>
339337
<br/>
340-
<a class="link" href="https://github.com/example/oxygen/issues" rel="ugc">View/report issues</a>
341-
<br/>
342338
<a class="link" href="https://github.com/example/oxygen/blob/master/CONTRIBUTING.md" rel="ugc">Contributing</a>
343339
<br/>
344340
</p>

app/test/frontend/golden/pkg_install_page.html

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -284,8 +284,6 @@ <h3 class="title pkg-infobox-metadata">Metadata</h3>
284284
<br/>
285285
<a class="link" href="https://github.com/example/oxygen" rel="ugc">Repository (GitHub)</a>
286286
<br/>
287-
<a class="link" href="https://github.com/example/oxygen/issues" rel="ugc">View/report issues</a>
288-
<br/>
289287
<a class="link" href="https://github.com/example/oxygen/blob/master/CONTRIBUTING.md" rel="ugc">Contributing</a>
290288
<br/>
291289
</p>
@@ -363,8 +361,6 @@ <h3 class="title pkg-infobox-metadata">Metadata</h3>
363361
<br/>
364362
<a class="link" href="https://github.com/example/oxygen" rel="ugc">Repository (GitHub)</a>
365363
<br/>
366-
<a class="link" href="https://github.com/example/oxygen/issues" rel="ugc">View/report issues</a>
367-
<br/>
368364
<a class="link" href="https://github.com/example/oxygen/blob/master/CONTRIBUTING.md" rel="ugc">Contributing</a>
369365
<br/>
370366
</p>

app/test/frontend/golden/pkg_score_page.html

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -346,8 +346,6 @@ <h3 class="title pkg-infobox-metadata">Metadata</h3>
346346
<br/>
347347
<a class="link" href="https://github.com/example/oxygen" rel="ugc">Repository (GitHub)</a>
348348
<br/>
349-
<a class="link" href="https://github.com/example/oxygen/issues" rel="ugc">View/report issues</a>
350-
<br/>
351349
<a class="link" href="https://github.com/example/oxygen/blob/master/CONTRIBUTING.md" rel="ugc">Contributing</a>
352350
<br/>
353351
</p>
@@ -425,8 +423,6 @@ <h3 class="title pkg-infobox-metadata">Metadata</h3>
425423
<br/>
426424
<a class="link" href="https://github.com/example/oxygen" rel="ugc">Repository (GitHub)</a>
427425
<br/>
428-
<a class="link" href="https://github.com/example/oxygen/issues" rel="ugc">View/report issues</a>
429-
<br/>
430426
<a class="link" href="https://github.com/example/oxygen/blob/master/CONTRIBUTING.md" rel="ugc">Contributing</a>
431427
<br/>
432428
</p>

app/test/frontend/golden/pkg_score_page_with_downloads_chart.html

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -346,8 +346,6 @@ <h3 class="title pkg-infobox-metadata">Metadata</h3>
346346
<br/>
347347
<a class="link" href="https://github.com/example/oxygen" rel="ugc">Repository (GitHub)</a>
348348
<br/>
349-
<a class="link" href="https://github.com/example/oxygen/issues" rel="ugc">View/report issues</a>
350-
<br/>
351349
<a class="link" href="https://github.com/example/oxygen/blob/master/CONTRIBUTING.md" rel="ugc">Contributing</a>
352350
<br/>
353351
</p>
@@ -425,8 +423,6 @@ <h3 class="title pkg-infobox-metadata">Metadata</h3>
425423
<br/>
426424
<a class="link" href="https://github.com/example/oxygen" rel="ugc">Repository (GitHub)</a>
427425
<br/>
428-
<a class="link" href="https://github.com/example/oxygen/issues" rel="ugc">View/report issues</a>
429-
<br/>
430426
<a class="link" href="https://github.com/example/oxygen/blob/master/CONTRIBUTING.md" rel="ugc">Contributing</a>
431427
<br/>
432428
</p>

app/test/frontend/golden/pkg_show_page.html

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -261,8 +261,6 @@ <h3 class="title pkg-infobox-metadata">Metadata</h3>
261261
<br/>
262262
<a class="link" href="https://github.com/example/oxygen" rel="ugc">Repository (GitHub)</a>
263263
<br/>
264-
<a class="link" href="https://github.com/example/oxygen/issues" rel="ugc">View/report issues</a>
265-
<br/>
266264
<a class="link" href="https://github.com/example/oxygen/blob/master/CONTRIBUTING.md" rel="ugc">Contributing</a>
267265
<br/>
268266
</p>
@@ -340,8 +338,6 @@ <h3 class="title pkg-infobox-metadata">Metadata</h3>
340338
<br/>
341339
<a class="link" href="https://github.com/example/oxygen" rel="ugc">Repository (GitHub)</a>
342340
<br/>
343-
<a class="link" href="https://github.com/example/oxygen/issues" rel="ugc">View/report issues</a>
344-
<br/>
345341
<a class="link" href="https://github.com/example/oxygen/blob/master/CONTRIBUTING.md" rel="ugc">Contributing</a>
346342
<br/>
347343
</p>

app/test/frontend/golden/pkg_show_page_discontinued.html

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -250,12 +250,8 @@ <h3 class="title">Weekly Downloads</h3>
250250
<h3 class="title pkg-infobox-metadata">Metadata</h3>
251251
<p>pkg is awesome</p>
252252
<p>
253-
<a class="link" href="https://pkg.example.com/" rel="ugc">Homepage</a>
254-
<br/>
255253
<a class="link" href="https://github.com/example/pkg" rel="ugc">Repository (GitHub)</a>
256254
<br/>
257-
<a class="link" href="https://github.com/example/pkg/issues" rel="ugc">View/report issues</a>
258-
<br/>
259255
<a class="link" href="https://github.com/example/pkg/blob/main/CONTRIBUTING.md" rel="ugc">Contributing</a>
260256
<br/>
261257
</p>
@@ -329,12 +325,8 @@ <h3 class="title">Weekly Downloads</h3>
329325
<h3 class="title pkg-infobox-metadata">Metadata</h3>
330326
<p>pkg is awesome</p>
331327
<p>
332-
<a class="link" href="https://pkg.example.com/" rel="ugc">Homepage</a>
333-
<br/>
334328
<a class="link" href="https://github.com/example/pkg" rel="ugc">Repository (GitHub)</a>
335329
<br/>
336-
<a class="link" href="https://github.com/example/pkg/issues" rel="ugc">View/report issues</a>
337-
<br/>
338330
<a class="link" href="https://github.com/example/pkg/blob/main/CONTRIBUTING.md" rel="ugc">Contributing</a>
339331
<br/>
340332
</p>

0 commit comments

Comments
 (0)