Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ private async Task FetchAndValidateCrossLinks(IDiagnosticsCollector collector, s
if (!string.IsNullOrEmpty(updateRepository) && updateReference is not null)
crossLinks = crossLinkResolver.UpdateLinkReference(updateRepository, updateReference);

var skippedPhantoms = 0;
foreach (var (repository, linkReference) in crossLinks.LinkReferences)
{
if (!_repositories.Contains(repository))
Expand All @@ -117,14 +116,9 @@ private async Task FetchAndValidateCrossLinks(IDiagnosticsCollector collector, s
var path = relativeLink.Split('/').SkipLast(1);
var pathUri = new Uri($"{repository}://{string.Join('/', path)}");

var baseOfAPhantom = _phantoms.Any(p => p == pathUri);
var baseOfAPhantom = _phantoms.Any(p => IsPhantomOrDescendant(p, pathUri));
if (baseOfAPhantom)
{
skippedPhantoms++;
if (skippedPhantoms > _phantoms.Count * 3)
collector.EmitError(repository, $"Too many items are being marked as part of a phantom this looks like a bug. ({skippedPhantoms})");
continue;
}
collector.EmitError(repository, $"'Can not validate '{crossLink}' it's not declared in any link reference nor is it a phantom");
continue;
}
Expand Down Expand Up @@ -157,6 +151,12 @@ private async Task FetchAndValidateCrossLinks(IDiagnosticsCollector collector, s
}
}

private static bool IsPhantomOrDescendant(Uri phantom, Uri candidate) =>
candidate.Scheme == phantom.Scheme &&
candidate.Host == phantom.Host &&
(candidate.AbsolutePath == phantom.AbsolutePath ||
candidate.AbsolutePath.StartsWith(phantom.AbsolutePath.TrimEnd('/') + '/', StringComparison.Ordinal));

private async Task<RepositoryLinks> ReadLocalLinksJsonAsync(string localLinksJson, Cancel ctx)
{
try
Expand Down
Loading