Skip to content

Commit 2a4c921

Browse files
isaacbmillerampagentIsaac Miller
authored
fix: preserve versioned docs trailing slashes (#10448)
Amp-Thread-ID: https://ampcode.com/threads/T-01a0343f-9594-7503-aa47-5398838f8b9f Co-authored-by: Amp <amp@ampcode.com> Co-authored-by: Isaac Miller <isaac@cmpnd.ai>
1 parent 7b0d899 commit 2a4c921

2 files changed

Lines changed: 25 additions & 1 deletion

File tree

‎docs/scripts/publish_versioned_docs.py‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,18 @@
2222
"framework": None,
2323
"buildCommand": "true",
2424
"outputDirectory": ".",
25-
"trailingSlash": True,
25+
"redirects": [
26+
{
27+
"source": "/:version(\\d+\\.\\d+(?:\\.\\d+(?:(?:a|b|rc)\\d+)?)?)",
28+
"destination": "/:version/",
29+
"permanent": True,
30+
},
31+
{
32+
"source": "/:path((?:.*/)?[^./]+)",
33+
"destination": "/:path/",
34+
"permanent": True,
35+
},
36+
],
2637
"headers": [
2738
{
2839
"source": "/(.*).md",

‎tests/docs/test_versioned_docs.py‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,19 @@ def test_mike_current_is_mutable_and_default(tmp_path):
214214
assert host_config["framework"] is None
215215
assert host_config["buildCommand"] == "true"
216216
assert host_config["outputDirectory"] == "."
217+
assert host_config["redirects"] == [
218+
{
219+
"source": r"/:version(\d+\.\d+(?:\.\d+(?:(?:a|b|rc)\d+)?)?)",
220+
"destination": "/:version/",
221+
"permanent": True,
222+
},
223+
{
224+
"source": "/:path((?:.*/)?[^./]+)",
225+
"destination": "/:path/",
226+
"permanent": True,
227+
},
228+
]
229+
assert "trailingSlash" not in host_config
217230
production_inventory = subprocess.run(
218231
["git", "cat-file", "-e", "master:versions.json"], cwd=repository, capture_output=True
219232
)

0 commit comments

Comments
 (0)