@prunellejs/seo 0.7.4 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/src/index.ts +4 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prunellejs/seo",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "SEO meta, JSON-LD, sitemap, redirects, and self-hosted fonts plugin for Prunelle",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -21,6 +21,6 @@
|
|
|
21
21
|
"directory": "packages/plugin-seo"
|
|
22
22
|
},
|
|
23
23
|
"peerDependencies": {
|
|
24
|
-
"prunelle": "^0.
|
|
24
|
+
"prunelle": "^0.8.0"
|
|
25
25
|
}
|
|
26
26
|
}
|
package/src/index.ts
CHANGED
|
@@ -586,11 +586,11 @@ export function seo(options: SeoPluginOptions = {}): PrunellePlugin {
|
|
|
586
586
|
if (res.status >= 400 && seoCanonicalRequests.has(ctx.request) && !res.headers.has('content-encoding') && (res.headers.get('content-type') ?? '').includes('text/html')) {
|
|
587
587
|
const html = await res.text()
|
|
588
588
|
const cleaned = html.replace(CANONICAL_LINK_RE, '')
|
|
589
|
-
|
|
590
|
-
|
|
589
|
+
const headers = new Headers(res.headers)
|
|
590
|
+
// The body is read, so the original Response is spent: hand back a fresh one even when nothing was stripped.
|
|
591
|
+
if (cleaned !== html)
|
|
591
592
|
headers.delete('content-length')
|
|
592
|
-
|
|
593
|
-
}
|
|
593
|
+
return new Response(cleaned, { status: res.status, statusText: res.statusText, headers })
|
|
594
594
|
}
|
|
595
595
|
return res
|
|
596
596
|
}, { scope: 'dynamic' })
|