fix: canonical and social URLs answered as paths become absolute on the request origin

This commit is contained in:
Jakub Zych
2026-10-31 13:53:30 +01:00
parent ac59f3c80d
commit 7d52c5d2e5
8 changed files with 192 additions and 32 deletions

View File

@@ -49,3 +49,8 @@ report /posts/nope
200 /google0123.html contains=google-site-verification: google0123.html header=X-Content-Type-Options: nosniff
404 /unknown0123.html
404 /robots.txt
# A backend without a site URL answers paths: they become absolute on the
# request's origin.
200 /relative contains=<link rel="canonical" href="http://127.0.0.1:
200 /relative contains=/img/rel.png"> notcontains=content="/img/rel.png"

View File

@@ -1,38 +1,158 @@
{
"/": {
"action": "ok", "status": 200, "url": "https://acme.test/", "locale": "en", "staging": false,
"action": "ok",
"status": 200,
"url": "https://acme.test/",
"locale": "en",
"staging": false,
"seo": {
"title": "Home | Acme", "description": "Acme home", "canonical": "https://acme.test/",
"robots": "index, follow", "x_robots_tag": "index, follow",
"og": { "title": "Home | Acme", "description": "Acme home", "image": "https://acme.test/home.png", "url": "https://acme.test/" },
"twitter": { "card": "summary_large_image", "site": "@acme" },
"title": "Home | Acme",
"description": "Acme home",
"canonical": "https://acme.test/",
"robots": "index, follow",
"x_robots_tag": "index, follow",
"og": {
"title": "Home | Acme",
"description": "Acme home",
"image": "https://acme.test/home.png",
"url": "https://acme.test/"
},
"twitter": {
"card": "summary_large_image",
"site": "@acme"
},
"verification": []
}
},
"/about": {
"action": "ok", "status": 200, "url": "https://acme.test/about", "locale": "en", "staging": false,
"action": "ok",
"status": 200,
"url": "https://acme.test/about",
"locale": "en",
"staging": false,
"seo": {
"title": "About us | Acme", "description": "Who we are", "canonical": "https://acme.test/about",
"robots": "index, follow, max-image-preview:large", "x_robots_tag": "index, follow, max-image-preview:large",
"og": { "title": "About us | Acme", "description": "Who we are", "image": "", "url": "https://acme.test/about" },
"twitter": { "card": "summary", "site": "@acme" },
"verification": [{ "name": "google-site-verification", "content": "fixture-google-code" }]
"title": "About us | Acme",
"description": "Who we are",
"canonical": "https://acme.test/about",
"robots": "index, follow, max-image-preview:large",
"x_robots_tag": "index, follow, max-image-preview:large",
"og": {
"title": "About us | Acme",
"description": "Who we are",
"image": "",
"url": "https://acme.test/about"
},
"twitter": {
"card": "summary",
"site": "@acme"
},
"verification": [
{
"name": "google-site-verification",
"content": "fixture-google-code"
}
]
}
},
"/partial": {
"action": "ok", "status": 200, "url": "https://acme.test/partial", "locale": "en", "staging": false,
"action": "ok",
"status": 200,
"url": "https://acme.test/partial",
"locale": "en",
"staging": false,
"seo": {
"title": "", "description": "", "canonical": "https://acme.test/partial",
"robots": "", "x_robots_tag": "",
"og": { "title": "", "description": "", "image": "", "url": "" },
"twitter": { "card": "", "site": "" },
"title": "",
"description": "",
"canonical": "https://acme.test/partial",
"robots": "",
"x_robots_tag": "",
"og": {
"title": "",
"description": "",
"image": "",
"url": ""
},
"twitter": {
"card": "",
"site": ""
},
"verification": []
}
},
"/staging": { "action": "not_found", "status": 404, "url": "https://acme.test/staging", "locale": "", "staging": true, "seo": null },
"/old-path": { "action": "redirect", "status": 301, "location": "https://acme.test/about", "url": "https://acme.test/old-path", "locale": "", "staging": false, "seo": null },
"/old-temp?ref=1": { "action": "redirect", "status": 302, "location": "https://acme.test/about?x=1", "url": "https://acme.test/old-temp?ref=1", "locale": "", "staging": false, "seo": null },
"/moved": { "action": "redirect", "status": 301, "location": "https://other.test/x", "url": "https://acme.test/moved", "locale": "", "staging": false, "seo": null },
"/gone-path": { "action": "gone", "status": 410, "url": "https://acme.test/gone-path", "locale": "", "staging": false, "seo": null },
"/posts/gone-post": { "action": "gone", "status": 410, "url": "https://acme.test/posts/gone-post", "locale": "", "staging": false, "seo": null }
"/staging": {
"action": "not_found",
"status": 404,
"url": "https://acme.test/staging",
"locale": "",
"staging": true,
"seo": null
},
"/old-path": {
"action": "redirect",
"status": 301,
"location": "https://acme.test/about",
"url": "https://acme.test/old-path",
"locale": "",
"staging": false,
"seo": null
},
"/old-temp?ref=1": {
"action": "redirect",
"status": 302,
"location": "https://acme.test/about?x=1",
"url": "https://acme.test/old-temp?ref=1",
"locale": "",
"staging": false,
"seo": null
},
"/moved": {
"action": "redirect",
"status": 301,
"location": "https://other.test/x",
"url": "https://acme.test/moved",
"locale": "",
"staging": false,
"seo": null
},
"/gone-path": {
"action": "gone",
"status": 410,
"url": "https://acme.test/gone-path",
"locale": "",
"staging": false,
"seo": null
},
"/posts/gone-post": {
"action": "gone",
"status": 410,
"url": "https://acme.test/posts/gone-post",
"locale": "",
"staging": false,
"seo": null
},
"/relative": {
"action": "ok",
"status": 200,
"url": "/relative",
"locale": "en",
"staging": false,
"seo": {
"title": "Relative | Acme",
"description": "",
"canonical": "/relative",
"robots": "",
"x_robots_tag": "",
"og": {
"title": "",
"description": "",
"image": "/img/rel.png",
"url": "/relative"
},
"twitter": {
"card": "",
"site": ""
},
"verification": []
}
}
}