Skip to content

Commit

Permalink
πŸš€πŸš€πŸš€ (#8185)
Browse files Browse the repository at this point in the history
* fix: return LinkType.External if host name is not removed (#8182)

* Update default document url in language server (#8183)

Co-authored-by: Ying Hua <[email protected]>
  • Loading branch information
928PJY and herohua authored Sep 23, 2022
1 parent 4900a54 commit 9f62922
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docs/specs/lsp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ languageServer:
a.md: "[Test](non-existed.md)"
- expectDiagnostics:
a.md: []
docfx.yml: [{ "code": "yaml-syntax-error" }]
docfx.yml: [{ "code": "yaml-syntax-error", "codeDescription": { "href": "https://review.learn.microsoft.com/en-us/help/contribute/validation-ref/doc-not-available?branch=main" } }]
- editFiles:
docfx.yml:
- expectDiagnostics:
Expand Down
2 changes: 1 addition & 1 deletion src/docfx/build/link/LinkResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public LinkResolver(
resolvedHref = UrlUtility.RemoveLeadingHostName(resolvedHref, _config.AlternativeHostName);
}

return (errors, resolvedHref, fragment, LinkType.AbsolutePath, null, false);
return (errors, resolvedHref, fragment, resolvedHref != href ? LinkType.AbsolutePath : LinkType.External, null, false);
}

// Cannot resolve the file, leave href as is
Expand Down
2 changes: 1 addition & 1 deletion src/docfx/serve/LanguageServerBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ private void PublishDiagnosticsParams(ErrorList errors, IEnumerable<PathString>

private static Diagnostic ConvertToDiagnostics(Error error, SourceInfo source)
{
var documentUrl = error.DocumentUrl ?? "https://review.docs.microsoft.com/en-us/help/contribute/validation-ref/doc-not-available?branch=main";
var documentUrl = error.DocumentUrl ?? "https://review.learn.microsoft.com/en-us/help/contribute/validation-ref/doc-not-available?branch=main";
return new Diagnostic
{
Range = new(
Expand Down
4 changes: 4 additions & 0 deletions test/docfx.Test/lib/UrlUtilityTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,10 @@ public static void StandardizeBookmarks(string uid, string expectedBookmark)
[InlineData("https://docs.com/c", "docs.com", false, "/c")]
[InlineData("https://docs.com/en-us/c", "docs1.com", true, "https://docs.com/en-us/c")]
[InlineData("https://docs.com/", "docs.com", true, "/")]
[InlineData("https://docs.com/#bookmark", "docs.com", true, "/#bookmark")]
[InlineData("https://docs.com/?query=value", "docs1.com", true, "https://docs.com/?query=value")]
[InlineData("https://docs.com/c#bookmark", "docs1.com", true, "https://docs.com/c#bookmark")]
[InlineData("https://docs.com/c?query=value", "docs.com", true, "/c?query=value")]
public static void RemoveHostName(string url, string hostName, bool removeLocale, string expected)
{
var result = UrlUtility.RemoveLeadingHostName(url, hostName, removeLocale);
Expand Down

0 comments on commit 9f62922

Please sign in to comment.