Skip to content

Commit 3389216

Browse files
committed
Style adjustments and touch up lookup path construction
1 parent 28093ab commit 3389216

File tree

3 files changed

+40
-15
lines changed

3 files changed

+40
-15
lines changed

src/Elastic.Markdown/Links/CrossLinks/CrossLinkResolver.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ private static bool FinalizeRedirect(
168168

169169
if (Uri.TryCreate(redirectToPath, UriKind.Absolute, out var targetCrossUri) && targetCrossUri.Scheme != "http" && targetCrossUri.Scheme != "https")
170170
{
171-
var lookupPath = Path.Combine(targetCrossUri.Host, targetCrossUri.AbsolutePath.TrimStart('/'));
171+
var lookupPath = $"{targetCrossUri.Host}/{targetCrossUri.AbsolutePath.TrimStart('/')}";
172172
finalPathForResolver = ToTargetUrlPath(lookupPath);
173173

174174
if (!string.IsNullOrEmpty(targetFragment) && targetFragment != "!")

tests/authoring/Framework/CrossLinkResolverAssertions.fs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ module CrossLinkResolverAssertions =
6363
LinkIndexEntries = FrozenDictionary<string, LinkRegistryEntry>.Empty
6464
)
6565

66+
// language=yaml
6667
let private redirectsYaml = """
6768
# test scenario 1
6869
'testing/redirects/multi-topic-page-1-old.md':

tests/authoring/Inline/CrossLinkRedirectAnchors.fs

Lines changed: 38 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,55 +7,79 @@ module ``inline elements``.``complex anchors``
77
open Xunit
88
open authoring.CrossLinkResolverAssertions
99

10-
type ``scenario 1``() =
10+
type ``Scenario 1: complex redirect mapping with anchor dropping for fallback redirects``() =
1111

1212
[<Fact>]
1313
let ``No anchor redirects to new-anchorless page``() =
14-
resolvesTo ("docs-content://testing/redirects/multi-topic-page-1-old.md") "/testing/redirects/multi-topic-page-1-new-anchorless"
14+
resolvesTo
15+
"docs-content://testing/redirects/multi-topic-page-1-old.md"
16+
"/testing/redirects/multi-topic-page-1-new-anchorless"
1517

1618
[<Fact>]
1719
let ``Unmatched anchor for '!' rule redirects to new-anchorless page and drops anchor``() =
18-
resolvesTo ("docs-content://testing/redirects/multi-topic-page-1-old.md#unmatched-anchor") "/testing/redirects/multi-topic-page-1-new-anchorless"
20+
resolvesTo
21+
"docs-content://testing/redirects/multi-topic-page-1-old.md#unmatched-anchor"
22+
"/testing/redirects/multi-topic-page-1-new-anchorless"
1923

2024
[<Fact>]
2125
let ``topic-a-intro redirects to topic-a-subpage and drops anchor (null target)``() =
22-
resolvesTo ("docs-content://testing/redirects/multi-topic-page-1-old.md#topic-a-intro") "/testing/redirects/multi-topic-page-1-new-topic-a-subpage"
26+
resolvesTo
27+
"docs-content://testing/redirects/multi-topic-page-1-old.md#topic-a-intro"
28+
"/testing/redirects/multi-topic-page-1-new-topic-a-subpage"
2329

2430
[<Fact>]
2531
let ``topic-a-details redirects to topic-a-subpage with new anchor``() =
26-
resolvesTo ("docs-content://testing/redirects/multi-topic-page-1-old.md#topic-a-details") "/testing/redirects/multi-topic-page-1-new-topic-a-subpage#details-anchor"
32+
resolvesTo
33+
"docs-content://testing/redirects/multi-topic-page-1-old.md#topic-a-details"
34+
"/testing/redirects/multi-topic-page-1-new-topic-a-subpage#details-anchor"
2735

2836
[<Fact>]
2937
let ``topic-b-main redirects to topic-b-subpage with new anchor``() =
30-
resolvesTo ("docs-content://testing/redirects/multi-topic-page-1-old.md#topic-b-main") "/testing/redirects/multi-topic-page-1-new-topic-b-subpage#main-anchor"
38+
resolvesTo
39+
"docs-content://testing/redirects/multi-topic-page-1-old.md#topic-b-main"
40+
"/testing/redirects/multi-topic-page-1-new-topic-b-subpage#main-anchor"
3141

3242
[<Fact>]
3343
let ``topic-c-main redirects to old page and keeps anchor``() =
34-
resolvesTo ("docs-content://testing/redirects/multi-topic-page-1-old.md#topic-c-main") "/testing/redirects/multi-topic-page-1-old#topic-c-main"
44+
resolvesTo
45+
"docs-content://testing/redirects/multi-topic-page-1-old.md#topic-c-main"
46+
"/testing/redirects/multi-topic-page-1-old#topic-c-main"
3547

3648

37-
type ``Scenario 2``() =
49+
type ``Scenario 2: complex redirect mapping with anchor passing for fallback redirects``() =
3850

3951
[<Fact>]
4052
let ``No anchor redirects to old page (self)``() =
41-
resolvesTo ("docs-content://testing/redirects/multi-topic-page-2-old.md") "/testing/redirects/multi-topic-page-2-old"
53+
resolvesTo
54+
"docs-content://testing/redirects/multi-topic-page-2-old.md"
55+
"/testing/redirects/multi-topic-page-2-old"
4256

4357
[<Fact>]
4458
let ``Unmatched anchor for '{}' rule redirects to old page (self) and keeps anchor``() =
45-
resolvesTo ("docs-content://testing/redirects/multi-topic-page-2-old.md#unmatched-anchor") "/testing/redirects/multi-topic-page-2-old#unmatched-anchor"
59+
resolvesTo
60+
"docs-content://testing/redirects/multi-topic-page-2-old.md#unmatched-anchor"
61+
"/testing/redirects/multi-topic-page-2-old#unmatched-anchor"
4662

4763
[<Fact>]
4864
let ``topic-a-intro redirects to topic-a-subpage with new anchor``() =
49-
resolvesTo ("docs-content://testing/redirects/multi-topic-page-2-old.md#topic-a-intro") "/testing/redirects/multi-topic-page-2-new-topic-a-subpage#introduction"
65+
resolvesTo
66+
"docs-content://testing/redirects/multi-topic-page-2-old.md#topic-a-intro"
67+
"/testing/redirects/multi-topic-page-2-new-topic-a-subpage#introduction"
5068

5169
[<Fact>]
5270
let ``topic-a-details redirects to topic-a-subpage and drops anchor (null target)``() =
53-
resolvesTo ("docs-content://testing/redirects/multi-topic-page-2-old.md#topic-a-details") "/testing/redirects/multi-topic-page-2-new-topic-a-subpage"
71+
resolvesTo
72+
"docs-content://testing/redirects/multi-topic-page-2-old.md#topic-a-details"
73+
"/testing/redirects/multi-topic-page-2-new-topic-a-subpage"
5474

5575
[<Fact>]
5676
let ``topic-b-main redirects to topic-b-subpage with new anchor``() =
57-
resolvesTo ("docs-content://testing/redirects/multi-topic-page-2-old.md#topic-b-main") "/testing/redirects/multi-topic-page-2-new-topic-b-subpage#summary"
77+
resolvesTo
78+
"docs-content://testing/redirects/multi-topic-page-2-old.md#topic-b-main"
79+
"/testing/redirects/multi-topic-page-2-new-topic-b-subpage#summary"
5880

5981
[<Fact>]
6082
let ``topic-b-config redirects to topic-b-subpage and drops anchor (null target)``() =
61-
resolvesTo ("docs-content://testing/redirects/multi-topic-page-2-old.md#topic-b-config") "/testing/redirects/multi-topic-page-2-new-topic-b-subpage"
83+
resolvesTo
84+
"docs-content://testing/redirects/multi-topic-page-2-old.md#topic-b-config"
85+
"/testing/redirects/multi-topic-page-2-new-topic-b-subpage"

0 commit comments

Comments
 (0)