Skip to content

Commit 2d70836

Browse files
theletterfclaude
andcommitted
fix: phantom prefix matching and remove phantom skip cap
Phantoms now correctly cover all descendants, not just direct children. The hard cap on phantom-skipped files is removed. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 6df91a3 commit 2d70836

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

src/services/Elastic.Documentation.Assembler/Navigation/NavigationPrefixChecker.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ private async Task FetchAndValidateCrossLinks(IDiagnosticsCollector collector, s
9999
if (!string.IsNullOrEmpty(updateRepository) && updateReference is not null)
100100
crossLinks = crossLinkResolver.UpdateLinkReference(updateRepository, updateReference);
101101

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

120-
var baseOfAPhantom = _phantoms.Any(p => p == pathUri);
119+
var baseOfAPhantom = _phantoms.Any(p => IsPhantomOrDescendant(p, pathUri));
121120
if (baseOfAPhantom)
122-
{
123-
skippedPhantoms++;
124-
if (skippedPhantoms > _phantoms.Count * 3)
125-
collector.EmitError(repository, $"Too many items are being marked as part of a phantom this looks like a bug. ({skippedPhantoms})");
126121
continue;
127-
}
128122
collector.EmitError(repository, $"'Can not validate '{crossLink}' it's not declared in any link reference nor is it a phantom");
129123
continue;
130124
}
@@ -157,6 +151,12 @@ private async Task FetchAndValidateCrossLinks(IDiagnosticsCollector collector, s
157151
}
158152
}
159153

154+
private static bool IsPhantomOrDescendant(Uri phantom, Uri candidate) =>
155+
candidate.Scheme == phantom.Scheme &&
156+
candidate.Host == phantom.Host &&
157+
(candidate.AbsolutePath == phantom.AbsolutePath ||
158+
candidate.AbsolutePath.StartsWith(phantom.AbsolutePath.TrimEnd('/') + '/'));
159+
160160
private async Task<RepositoryLinks> ReadLocalLinksJsonAsync(string localLinksJson, Cancel ctx)
161161
{
162162
try

0 commit comments

Comments
 (0)