Skip to content

Commit

Permalink
fix conditionally appending url path prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
Mpdreamz committed Dec 10, 2024
1 parent 1ce03dc commit 3f6b3bb
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,11 @@ public override bool Match(InlineProcessor processor, ref StringSlice slice)
}

if (url.EndsWith(".md"))
link.Url = $"{processor.GetBuildContext().UrlPathPrefix}/{Path.ChangeExtension(url, ".html")}";
link.Url = Path.ChangeExtension(url, ".html");
// rooted links might need the configured path prefix to properly link
var prefix = processor.GetBuildContext().UrlPathPrefix;
if (url.StartsWith("/") && !string.IsNullOrWhiteSpace(prefix))
link.Url = $"{prefix}/{link.Url}";

if (!string.IsNullOrEmpty(anchor))
link.Url += $"#{anchor}";
Expand Down

0 comments on commit 3f6b3bb

Please sign in to comment.