Skip to content
Merged
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
22 changes: 17 additions & 5 deletions src/tooling/docs-assembler/Building/AssemblerBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ await OutputRedirectsAsync(redirects
await Task.WhenAll(tasks);
}

private static void CollectRedirects(
private void CollectRedirects(
Dictionary<string, string> allRedirects,
IReadOnlyDictionary<string, LinkRedirect> redirects,
string repository,
Expand All @@ -121,11 +121,23 @@ ICrossLinkResolver linkResolver
allRedirects[Resolve(k)] = Resolve(t);
}
}
string Resolve(string relativeMarkdownPath)
string Resolve(string path)
{
var uri = linkResolver.UriResolver.Resolve(new Uri($"{repository}://{relativeMarkdownPath}"),
PublishEnvironmentUriResolver.MarkdownPathToUrlPath(relativeMarkdownPath));
return uri.AbsolutePath;
Uri? uri;
if (Uri.IsWellFormedUriString(path, UriKind.Absolute)) // Cross-repo links
{
_ = linkResolver.TryResolve(
(e) => _logger.LogError("An error occurred while resolving cross-link {Path}: {Error}", path, e),
new Uri(path),
out uri);
}
else // Relative links
{
uri = linkResolver.UriResolver.Resolve(new Uri($"{repository}://{path}"),
PublishEnvironmentUriResolver.MarkdownPathToUrlPath(path));
}

return uri?.AbsolutePath ?? string.Empty;
}
}

Expand Down
Loading