Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
reakaleek committed Feb 6, 2025
1 parent 83c37d2 commit d92266f
Showing 1 changed file with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -241,17 +241,22 @@ private static void UpdateLinkUrl(LinkInline link, string url, ParserContext con
if (url.EndsWith(".md"))
url = Path.ChangeExtension(url, ".html");

if (url.StartsWith("/") && !string.IsNullOrWhiteSpace(urlPathPrefix))

if (!url.StartsWith('/'))
url = GetRootRelativePath(context, file);

if (!string.IsNullOrWhiteSpace(urlPathPrefix))
url = $"{urlPathPrefix.TrimEnd('/')}{url}";
else
{
var docsetDirectory = context.Configuration.SourceFile.Directory;
url = file.FullName.Replace(docsetDirectory!.FullName, string.Empty);
}

link.Url = !string.IsNullOrEmpty(anchor) ? $"{url}#{anchor}" : url;
}

private static string GetRootRelativePath(ParserContext context, IFileInfo file)
{
var docsetDirectory = context.Configuration.SourceFile.Directory;
return file.FullName.Replace(docsetDirectory!.FullName, string.Empty);
}

private static bool IsCrossLink(Uri? uri) =>
uri != null // This means it's not a local
&& !ExcludedSchemes.Contains(uri.Scheme)
Expand Down

0 comments on commit d92266f

Please sign in to comment.