Skip to content

Commit 6586894

Browse files
committed
Include trailing / in PEP URL to avoid 301 redirect
1 parent a432bf8 commit 6586894

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

sphinx/roles.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,9 +193,9 @@ def build_uri(self) -> str:
193193
base_url = self.inliner.document.settings.pep_base_url
194194
ret = self.target.split('#', 1)
195195
if len(ret) == 2:
196-
return base_url + 'pep-%04d#%s' % (int(ret[0]), ret[1])
196+
return base_url + 'pep-%04d/#%s' % (int(ret[0]), ret[1])
197197
else:
198-
return base_url + 'pep-%04d' % int(ret[0])
198+
return base_url + 'pep-%04d/' % int(ret[0])
199199

200200

201201
class RFC(ReferenceRole):

tests/test_build_html.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,9 +212,9 @@ def test_html4_output(app, status, warning):
212212
(".//li/p/code/span[@class='pre']", '^a/$'),
213213
(".//li/p/code/em/span[@class='pre']", '^varpart$'),
214214
(".//li/p/code/em/span[@class='pre']", '^i$'),
215-
(".//a[@href='https://peps.python.org/pep-0008']"
215+
(".//a[@href='https://peps.python.org/pep-0008/']"
216216
"[@class='pep reference external']/strong", 'PEP 8'),
217-
(".//a[@href='https://peps.python.org/pep-0008']"
217+
(".//a[@href='https://peps.python.org/pep-0008/']"
218218
"[@class='pep reference external']/strong",
219219
'Python Enhancement Proposal #8'),
220220
(".//a[@href='https://datatracker.ietf.org/doc/html/rfc1.html']"

tests/test_markup.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,23 +150,23 @@ def get(name):
150150
'verify',
151151
':pep:`8`',
152152
('<p><span class="target" id="index-0"></span><a class="pep reference external" '
153-
'href="https://peps.python.org/pep-0008"><strong>PEP 8</strong></a></p>'),
153+
'href="https://peps.python.org/pep-0008/"><strong>PEP 8</strong></a></p>'),
154154
('\\sphinxAtStartPar\n'
155155
'\\index{Python Enhancement Proposals@\\spxentry{Python Enhancement Proposals}'
156-
'!PEP 8@\\spxentry{PEP 8}}\\sphinxhref{https://peps.python.org/pep-0008}'
156+
'!PEP 8@\\spxentry{PEP 8}}\\sphinxhref{https://peps.python.org/pep-0008/}'
157157
'{\\sphinxstylestrong{PEP 8}}')
158158
),
159159
(
160160
# pep role with anchor
161161
'verify',
162162
':pep:`8#id1`',
163163
('<p><span class="target" id="index-0"></span><a class="pep reference external" '
164-
'href="https://peps.python.org/pep-0008#id1">'
164+
'href="https://peps.python.org/pep-0008/#id1">'
165165
'<strong>PEP 8#id1</strong></a></p>'),
166166
('\\sphinxAtStartPar\n'
167167
'\\index{Python Enhancement Proposals@\\spxentry{Python Enhancement Proposals}'
168168
'!PEP 8\\#id1@\\spxentry{PEP 8\\#id1}}\\sphinxhref'
169-
'{https://peps.python.org/pep-0008\\#id1}'
169+
'{https://peps.python.org/pep-0008/\\#id1}'
170170
'{\\sphinxstylestrong{PEP 8\\#id1}}')
171171
),
172172
(

0 commit comments

Comments
 (0)