Include trailing / in PEP URL to avoid 301 redirect

This commit is contained in:
Hugo van Kemenade 2022-03-24 13:31:17 +02:00
parent a432bf8c10
commit 658689433e
3 changed files with 8 additions and 8 deletions

View File

@ -193,9 +193,9 @@ class PEP(ReferenceRole):
base_url = self.inliner.document.settings.pep_base_url
ret = self.target.split('#', 1)
if len(ret) == 2:
return base_url + 'pep-%04d#%s' % (int(ret[0]), ret[1])
return base_url + 'pep-%04d/#%s' % (int(ret[0]), ret[1])
else:
return base_url + 'pep-%04d' % int(ret[0])
return base_url + 'pep-%04d/' % int(ret[0])
class RFC(ReferenceRole):

View File

@ -212,9 +212,9 @@ def test_html4_output(app, status, warning):
(".//li/p/code/span[@class='pre']", '^a/$'),
(".//li/p/code/em/span[@class='pre']", '^varpart$'),
(".//li/p/code/em/span[@class='pre']", '^i$'),
(".//a[@href='https://peps.python.org/pep-0008']"
(".//a[@href='https://peps.python.org/pep-0008/']"
"[@class='pep reference external']/strong", 'PEP 8'),
(".//a[@href='https://peps.python.org/pep-0008']"
(".//a[@href='https://peps.python.org/pep-0008/']"
"[@class='pep reference external']/strong",
'Python Enhancement Proposal #8'),
(".//a[@href='https://datatracker.ietf.org/doc/html/rfc1.html']"

View File

@ -150,10 +150,10 @@ def get_verifier(verify, verify_re):
'verify',
':pep:`8`',
('<p><span class="target" id="index-0"></span><a class="pep reference external" '
'href="https://peps.python.org/pep-0008"><strong>PEP 8</strong></a></p>'),
'href="https://peps.python.org/pep-0008/"><strong>PEP 8</strong></a></p>'),
('\\sphinxAtStartPar\n'
'\\index{Python Enhancement Proposals@\\spxentry{Python Enhancement Proposals}'
'!PEP 8@\\spxentry{PEP 8}}\\sphinxhref{https://peps.python.org/pep-0008}'
'!PEP 8@\\spxentry{PEP 8}}\\sphinxhref{https://peps.python.org/pep-0008/}'
'{\\sphinxstylestrong{PEP 8}}')
),
(
@ -161,12 +161,12 @@ def get_verifier(verify, verify_re):
'verify',
':pep:`8#id1`',
('<p><span class="target" id="index-0"></span><a class="pep reference external" '
'href="https://peps.python.org/pep-0008#id1">'
'href="https://peps.python.org/pep-0008/#id1">'
'<strong>PEP 8#id1</strong></a></p>'),
('\\sphinxAtStartPar\n'
'\\index{Python Enhancement Proposals@\\spxentry{Python Enhancement Proposals}'
'!PEP 8\\#id1@\\spxentry{PEP 8\\#id1}}\\sphinxhref'
'{https://peps.python.org/pep-0008\\#id1}'
'{https://peps.python.org/pep-0008/\\#id1}'
'{\\sphinxstylestrong{PEP 8\\#id1}}')
),
(