diff --git a/src/Microsoft.DocAsCode.Build.Engine/LinkPhaseHandler.cs b/src/Microsoft.DocAsCode.Build.Engine/LinkPhaseHandler.cs
index 03c48ef9cf9..e76abee18af 100644
--- a/src/Microsoft.DocAsCode.Build.Engine/LinkPhaseHandler.cs
+++ b/src/Microsoft.DocAsCode.Build.Engine/LinkPhaseHandler.cs
@@ -150,11 +150,12 @@ private void CheckFileLink(FileModel model, HostService hostService, SaveResult
ToFileInSource = ((RelativePath)fileLink).RemoveWorkingFolder().ToString(),
FileLinkInSource = path,
GroupInfo = Context.GroupInfo,
+ Href = path.UrlEncode()
};
- fli.Href = path.UrlEncode();
- if (Context.ApplyTemplateSettings.HrefGenerator.GenerateHref(fli) != null)
+
+ if (Context.ApplyTemplateSettings.HrefGenerator.GenerateHref(fli) != fli.Href)
{
- return;
+ return; // if HrefGenerator returns new href. Skip InvalidFileLink check.
}
}
if (result.FileLinkSources.TryGetValue(fileLink, out ImmutableList ",
"test",
},
@@ -205,6 +207,8 @@ public void TestBuild()
Assert.NotNull(model[0].Items);
Assert.Equal("test2", model[0].Items[0].Name);
Assert.Equal("test/test.html", model[0].Items[0].Href);
+ Assert.Equal("GitHub", model[0].Items[1].Name);
+ Assert.Equal("GH.md?isAbbreviated=true&shouldBeAbbreviated=true#test", model[0].Items[1].Href);
Assert.Equal("Api", model[1].Name);
Assert.Null(model[1].Href);
Assert.NotNull(model[1].Items);
@@ -213,7 +217,7 @@ public void TestBuild()
Assert.Equal("ConsoleColor", model[1].Items[1].Name);
Assert.Equal("../System.ConsoleColor.csyml", model[1].Items[1].Href);
}
-
+
{
// check conceptual.
var conceptualOutputPath = Path.Combine(_outputFolder, Path.ChangeExtension(conceptualFile, ".html"));
@@ -251,7 +255,8 @@ public void TestBuild()
"Test invalid xref with attribute:
", @"test", "
"), @@ -284,7 +289,8 @@ public void TestBuild() "Test invalid xref with attribute: Foo<T>", "Test external xref with absolute URL and anchor: str", "Test invalid autolink xref: <xref:?displayProperty=fullName>", - "Test href generator: GitHub", + "Test href generator: GitHub", + "Test href generator: Git", "", "test", "
"),