Skip to content

Commit b518c86

Browse files
committed
Canonicalize docref urls before looking them up
The method ProjectNode::findDocumentEntry() expects canonicalized urls, and we fed it URLs that might be relative, leading to links not being resolved. Fixes #486
1 parent c8d9932 commit b518c86

File tree

7 files changed

+56
-1
lines changed

7 files changed

+56
-1
lines changed

packages/guides/src/ReferenceResolvers/DocReferenceResolver.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ public function resolve(LinkInlineNode $node, RenderContext $renderContext): boo
1818
return false;
1919
}
2020

21-
$document = $renderContext->getProjectNode()->findDocumentEntry($node->getTargetReference());
21+
$document = $renderContext->getProjectNode()->findDocumentEntry(
22+
$renderContext->canonicalUrl($node->getTargetReference()),
23+
);
2224
if ($document === null) {
2325
return false;
2426
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<title>Root</title>
5+
6+
</head>
7+
<body>
8+
<div class="section" id="root">
9+
<h1>Root</h1>
10+
11+
</div>
12+
13+
</body>
14+
</html>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<title>Subfolder index</title>
5+
6+
</head>
7+
<body>
8+
<div class="section" id="subfolder-index">
9+
<h1>Subfolder index</h1>
10+
11+
<p><a href="/index.html">Root</a></p>
12+
</div>
13+
14+
</body>
15+
</html>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
====
2+
Root
3+
====
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
===============
2+
Subfolder index
3+
===============
4+
5+
:doc:`../index`
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<title></title>
5+
6+
</head>
7+
<body>
8+
<p><a href="/page.html">Page 1</a></p>
9+
</body>
10+
</html>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
===============
2+
Subfolder index
3+
===============
4+
5+
6+
:doc:`../page`

0 commit comments

Comments
 (0)