Skip to content

Commit 2df6b8d

Browse files
committed
Lowercase links in the HTML to avoid making assumptions about a case insensitive hosting environment.
1 parent 49cb629 commit 2df6b8d

File tree

4 files changed

+28
-27
lines changed

4 files changed

+28
-27
lines changed

Sources/DocCHTML/MarkdownRenderer.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,7 @@ package struct MarkdownRenderer<Provider: LinkProvider> {
264264
+ toComponents.dropFirst(commonPrefixLength)
265265

266266
return relativeComponents.joined(separator: "/")
267+
.lowercased() // Don't make assumptions about a case insensitive hosting environment.
267268
}
268269

269270
func visit(_ image: Image) -> XMLNode {

Tests/DocCHTMLTests/MarkdownRenderer+PageElementsTests.swift

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -306,12 +306,12 @@ struct MarkdownRenderer_PageElementsTests {
306306
<span class="token-identifier">doSomething</span>
307307
(<span class="token-externalParam">with</span>
308308
<span class="token-internalParam">first</span>
309-
: <a class="token-typeIdentifier" href="../../FirstParameterValue/index.html">FirstParameterValue</a>
309+
: <a class="token-typeIdentifier" href="../../firstparametervalue/index.html">FirstParameterValue</a>
310310
, <span class="token-externalParam">and</span>
311311
<span class="token-internalParam">second</span>
312-
: <a class="token-typeIdentifier" href="../../SecondParameterValue/index.html">SecondParameterValue</a>
312+
: <a class="token-typeIdentifier" href="../../secondparametervalue/index.html">SecondParameterValue</a>
313313
) <span class="token-keyword">throws</span>
314-
-&gt; <a class="token-typeIdentifier" href="../../ReturnValue/index.html">ReturnValue</a>
314+
-&gt; <a class="token-typeIdentifier" href="../../returnvalue/index.html">ReturnValue</a>
315315
</code>
316316
</pre>
317317
""")
@@ -449,22 +449,22 @@ struct MarkdownRenderer_PageElementsTests {
449449
<span class="token-identifier">doSomething</span>
450450
(<span class="token-externalParam">with</span>
451451
<span class="token-internalParam">first</span>
452-
: <a class="token-typeIdentifier" href="../../FirstParameterValue/index.html">FirstParameterValue</a>
452+
: <a class="token-typeIdentifier" href="../../firstparametervalue/index.html">FirstParameterValue</a>
453453
, <span class="token-externalParam">and</span>
454454
<span class="token-internalParam">second</span>
455-
: <a class="token-typeIdentifier" href="../../SecondParameterValue/index.html">SecondParameterValue</a>
455+
: <a class="token-typeIdentifier" href="../../secondparametervalue/index.html">SecondParameterValue</a>
456456
) <span class="token-keyword">throws</span>
457-
-&gt; <a class="token-typeIdentifier" href="../../ReturnValue/index.html">ReturnValue</a>
457+
-&gt; <a class="token-typeIdentifier" href="../../returnvalue/index.html">ReturnValue</a>
458458
</code>
459-
<code class="occ-only">- (<a class="token-typeIdentifier" href="../../ReturnValue/index.html">ReturnValue</a>
459+
<code class="occ-only">- (<a class="token-typeIdentifier" href="../../returnvalue/index.html">ReturnValue</a>
460460
) <span class="token-identifier">doSomethingWithFirst</span>
461-
: (<a class="token-typeIdentifier" href="../../FirstParameterValue/index.html">FirstParameterValue</a>
461+
: (<a class="token-typeIdentifier" href="../../firstparametervalue/index.html">FirstParameterValue</a>
462462
) <span class="token-internalParam">first</span>
463463
<span class="token-identifier">andSecond</span>
464-
: (<a class="token-typeIdentifier" href="../../SecondParameterValue/index.html">SecondParameterValue</a>
464+
: (<a class="token-typeIdentifier" href="../../secondparametervalue/index.html">SecondParameterValue</a>
465465
) <span class="token-internalParam">second</span>
466466
<span class="token-identifier">error</span>
467-
: (<a class="token-typeIdentifier" href="../../../Foundation/NSError/index.html">NSError</a>
467+
: (<a class="token-typeIdentifier" href="../../../foundation/nserror/index.html">NSError</a>
468468
**) <span class="token-internalParam">error</span>
469469
;</code>
470470
</pre>
@@ -556,7 +556,7 @@ struct MarkdownRenderer_PageElementsTests {
556556
<p>Some description of this group</p>
557557
<ul>
558558
<li>
559-
<a href="../../SomeClass/index.html">
559+
<a href="../../someclass/index.html">
560560
<code class="swift-only">
561561
<span class="decorator">class </span>
562562
<span class="identifier">Some<wbr/>
@@ -572,15 +572,15 @@ struct MarkdownRenderer_PageElementsTests {
572572
</a>
573573
</li>
574574
<li>
575-
<a href="../../SomeArticle/index.html">
575+
<a href="../../somearticle/index.html">
576576
<p>Some Article</p>
577577
<p>Some <b>formatted</b>
578578
description of this <i>article</i>
579579
.</p>
580580
</a>
581581
</li>
582582
<li>
583-
<a href="../../SomeClass/someMethod(with:and:)/index.html">
583+
<a href="../../someclass/somemethod(with:and:)/index.html">
584584
<code class="swift-only">
585585
<span class="decorator">func </span>
586586
<span class="identifier">some<wbr/>
@@ -614,22 +614,22 @@ struct MarkdownRenderer_PageElementsTests {
614614
<p>Some description of this group</p>
615615
<ul>
616616
<li>
617-
<a href="../../SomeClass/index.html">
617+
<a href="../../someclass/index.html">
618618
<code>class SomeClass</code>
619619
<p>Some <i>formatted</i>
620620
description of this class</p>
621621
</a>
622622
</li>
623623
<li>
624-
<a href="../../SomeArticle/index.html">
624+
<a href="../../somearticle/index.html">
625625
<p>Some Article</p>
626626
<p>Some <b>formatted</b>
627627
description of this <i>article</i>
628628
.</p>
629629
</a>
630630
</li>
631631
<li>
632-
<a href="../../SomeClass/someMethod(with:and:)/index.html">
632+
<a href="../../someclass/somemethod(with:and:)/index.html">
633633
<code>func someMethod(with: Int, and: String)</code>
634634
</a>
635635
</li>

Tests/DocCHTMLTests/MarkdownRendererTests.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ struct MarkdownRendererTests {
369369
prettyFormatted: true,
370370
matches: """
371371
<p>
372-
<a href="../SomeArticle/index.html">Some Article Title</a>
372+
<a href="../somearticle/index.html">Some Article Title</a>
373373
</p>
374374
"""
375375
)
@@ -390,7 +390,7 @@ struct MarkdownRendererTests {
390390
prettyFormatted: true,
391391
matches: """
392392
<p>
393-
<a href="../SomeClass/someMethod(_:_:)/index.html">
393+
<a href="../someclass/somemethod(_:_:)/index.html">
394394
<code>some<wbr/>
395395
Method(<wbr/>
396396
_:<wbr/>
@@ -407,7 +407,7 @@ struct MarkdownRendererTests {
407407
prettyFormatted: true,
408408
matches: """
409409
<p>
410-
<a href="../SomeClass/someMethod(_:_:)/index.html">
410+
<a href="../someclass/somemethod(_:_:)/index.html">
411411
<code class="swift-only">do<wbr/>
412412
Something(<wbr/>
413413
with:<wbr/>
@@ -428,7 +428,7 @@ struct MarkdownRendererTests {
428428
rendering: "[Custom _formatted_ title](doc://com.example.test/documentation/Something/SomeClass/someMethod(_:_:))", // Simulate a link that's been locally resolved already
429429
elementToReturn: makeExampleMethodWithDifferentLanguageRepresentations(),
430430
matches: """
431-
<p><a href="../SomeClass/someMethod(_:_:)/index.html">Custom <i>formatted</i> title</a></p>
431+
<p><a href="../someclass/somemethod(_:_:)/index.html">Custom <i>formatted</i> title</a></p>
432432
"""
433433
)
434434

@@ -437,7 +437,7 @@ struct MarkdownRendererTests {
437437
rendering: "[Some `CustomSymbolName` title](doc://com.example.test/documentation/Something/SomeClass/someMethod(_:_:))", // Simulate a link that's been locally resolved already
438438
elementToReturn: makeExampleMethodWithDifferentLanguageRepresentations(),
439439
matches: """
440-
<p><a href="../SomeClass/someMethod(_:_:)/index.html">Some <code>Custom<wbr/>Symbol<wbr/>Name</code> title</a></p>
440+
<p><a href="../someclass/somemethod(_:_:)/index.html">Some <code>Custom<wbr/>Symbol<wbr/>Name</code> title</a></p>
441441
"""
442442
)
443443

Tests/SwiftDocCUtilitiesTests/FileWritingHTMLContentConsumerTests.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -209,14 +209,14 @@ final class FileWritingHTMLContentConsumerTests: XCTestCase {
209209
description of this topic section</p>
210210
<ul>
211211
<li>
212-
<a href="SomeArticle/index.html">
212+
<a href="somearticle/index.html">
213213
<p>Some article</p>
214214
<p>This is an <i>formatted</i>
215215
article.</p>
216216
</a>
217217
</li>
218218
<li>
219-
<a href="SomeClass/index.html">
219+
<a href="someclass/index.html">
220220
<code>class SomeClass</code>
221221
<p>Some in-source description of this class.</p>
222222
</a>
@@ -260,7 +260,7 @@ final class FileWritingHTMLContentConsumerTests: XCTestCase {
260260
<h3>Instance Methods</h3>
261261
<ul>
262262
<li>
263-
<a href="someMethod(with:and:)/index.html">
263+
<a href="somemethod(with:and:)/index.html">
264264
<code>func someMethod(with first: Int, and second: String) -&gt; Bool</code>
265265
<p>Some in-source description of this method.</p>
266266
</a>
@@ -324,7 +324,7 @@ final class FileWritingHTMLContentConsumerTests: XCTestCase {
324324
<h3>Related Documentation</h3>
325325
<ul>
326326
<li>
327-
<a href="../../SomeArticle/index.html">
327+
<a href="../../somearticle/index.html">
328328
<p>Some article</p>
329329
<p>This is an <i>formatted</i>
330330
article.</p>
@@ -360,7 +360,7 @@ final class FileWritingHTMLContentConsumerTests: XCTestCase {
360360
article.</p>
361361
</section>
362362
<h2>Custom discussion</h2>
363-
<p>It explains how a developer can perform some task using <a href="../SomeClass/index.html">
363+
<p>It explains how a developer can perform some task using <a href="../someclass/index.html">
364364
<code>SomeClass</code>
365365
</a>
366366
in this module.</p>
@@ -370,7 +370,7 @@ final class FileWritingHTMLContentConsumerTests: XCTestCase {
370370
<h3>Related Documentation</h3>
371371
<ul>
372372
<li>
373-
<a href="../SomeClass/index.html">
373+
<a href="../someclass/index.html">
374374
<code>class SomeClass</code>
375375
<p>Some in-source description of this class.</p>
376376
</a>

0 commit comments

Comments
 (0)