Skip to content

Commit dac0a61

Browse files
committed
ok
1 parent eecd4cc commit dac0a61

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

src/Elastic.Markdown/Myst/InlineParsers/DiagnosticLinkInlineParser.cs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -237,21 +237,18 @@ private static void ValidateAnchor(InlineProcessor processor, MarkdownFile markd
237237

238238
private static void UpdateLinkUrl(LinkInline link, string url, ParserContext context, string? anchor, IFileInfo file)
239239
{
240-
var newUrl = url;
241240
var urlPathPrefix = context.Build.UrlPathPrefix ?? string.Empty;
242241

243242
if (!url.StartsWith('/') && !string.IsNullOrEmpty(url))
244-
{
245-
newUrl = GetRootRelativePath(context, file);
246-
}
243+
url = GetRootRelativePath(context, file);
247244

248245
if (url.EndsWith(".md"))
249-
newUrl = Path.ChangeExtension(newUrl, ".html");
246+
url = Path.ChangeExtension(url, ".html");
250247

251-
if (!string.IsNullOrWhiteSpace(newUrl) && !string.IsNullOrWhiteSpace(urlPathPrefix))
252-
newUrl = $"{urlPathPrefix.TrimEnd('/')}{newUrl}";
248+
if (!string.IsNullOrWhiteSpace(url) && !string.IsNullOrWhiteSpace(urlPathPrefix))
249+
url = $"{urlPathPrefix.TrimEnd('/')}{url}";
253250

254-
link.Url = !string.IsNullOrEmpty(anchor) ? $"{newUrl}#{anchor}" : newUrl;
251+
link.Url = string.IsNullOrEmpty(anchor) ? url : $"{url}#{anchor}";
255252
}
256253

257254
private static string GetRootRelativePath(ParserContext context, IFileInfo file)

0 commit comments

Comments
 (0)