Skip to content

Commit 7d3d364

Browse files
committed
Refactor NavCrossLinkValidator
1 parent f51258d commit 7d3d364

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/Elastic.Markdown/IO/Navigation/NavigationCrossLinkValidator.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System;
66
using System.Collections.Generic;
77
using System.Threading.Tasks;
8+
using Elastic.Documentation.Links;
89
using Elastic.Documentation.Site.Navigation;
910
using Elastic.Markdown.Links.CrossLinks;
1011

@@ -29,7 +30,7 @@ public static async Task ValidateNavigationCrossLinksAsync(
2930
{
3031
var url = crossLinkItem.Url;
3132
if (url != null && Uri.TryCreate(url, UriKind.Absolute, out var crossUri) &&
32-
crossUri.Scheme != "http" && crossUri.Scheme != "https")
33+
CrossLinkValidator.IsCrossLink(crossUri))
3334
{
3435
// Try to resolve the cross-link URL
3536
if (crossLinkResolver.TryResolve(errorEmitter, crossUri, out var resolvedUri))
@@ -47,8 +48,7 @@ public static async Task ValidateNavigationCrossLinksAsync(
4748
else if (item is FileNavigationItem fileItem &&
4849
fileItem.Url != null &&
4950
Uri.TryCreate(fileItem.Url, UriKind.Absolute, out var fileUri) &&
50-
fileUri.Scheme != "http" &&
51-
fileUri.Scheme != "https")
51+
CrossLinkValidator.IsCrossLink(fileUri))
5252
{
5353
// Cross-link URL detected in a FileNavigationItem, but we're not validating it yet
5454
}
@@ -67,8 +67,7 @@ private static List<INavigationItem> FindNavigationItemsWithCrossLinks(INavigati
6767
var url = crossLinkItem.Url;
6868
if (url != null &&
6969
Uri.TryCreate(url, UriKind.Absolute, out var uri) &&
70-
uri.Scheme != "http" &&
71-
uri.Scheme != "https")
70+
CrossLinkValidator.IsCrossLink(uri))
7271
{
7372
results.Add(item);
7473
}

0 commit comments

Comments
 (0)