Skip to content

Commit 6605ced

Browse files
committed
Refactor
1 parent a590bb2 commit 6605ced

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

src/Elastic.Markdown/Myst/Directives/DirectiveHtmlRenderer.cs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -93,20 +93,14 @@ private static string GetRootRelativePath(ParserContext context, IFileInfo file)
9393

9494
private void WriteImage(HtmlRenderer renderer, ImageBlock block)
9595
{
96-
string imageUrl;
97-
98-
if (block.ImageUrl != null)
96+
var imageUrl = block.ImageUrl;
97+
if (!string.IsNullOrEmpty(block.ImageUrl))
9998
{
100-
if (block.ImageUrl.StartsWith("/_static") || block.ImageUrl.StartsWith("_static"))
101-
imageUrl = $"{block.Build.UrlPathPrefix}/{block.ImageUrl.TrimStart('/')}";
102-
else if (block.ImageUrl.StartsWith('/'))
99+
if (block.ImageUrl.StartsWith('/') || block.ImageUrl.StartsWith("_static"))
103100
imageUrl = $"{block.Build.UrlPathPrefix}/{block.ImageUrl.TrimStart('/')}";
104101
else
105102
imageUrl = block.Build.UrlPathPrefix + block.CurrentFile.DirectoryName!.Replace(block.Build.ConfigurationPath.DirectoryName!, "") + "/" + block.ImageUrl;
106103
}
107-
else
108-
imageUrl = block.ImageUrl!;
109-
110104
var slice = Image.Create(new ImageViewModel
111105
{
112106
Label = block.Label,

0 commit comments

Comments
 (0)