fix: HTML sitemap page 1 redirects with the locale's segment
- seoFirstPageRedirect answers the unnumbered URL or null when the target is the URL itself, so /mapa-strony/<group>/strona/1 no longer loops (L4 WR-01) - SeoHtmlSitemapPage takes the segment from the site answer, else the build option, else the param, and redirects only when the helper answers a target
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import assert from 'node:assert/strict'
|
||||
import test from 'node:test'
|
||||
import { seoPageHref, seoPageNumber } from '../app/utils/pageHref.ts'
|
||||
import { seoFirstPageRedirect, seoPageHref, seoPageNumber } from '../app/utils/pageHref.ts'
|
||||
import { seoFillPages } from '../app/utils/seo.ts'
|
||||
|
||||
test('seoPageHref: the UI-SPEC L2 examples', () => {
|
||||
@@ -45,3 +45,17 @@ test('seoFillPages: %pages% in the title and meta, only once the count is known'
|
||||
assert.equal(seoFillPages(head, null), head)
|
||||
assert.equal(seoFillPages(head, 0), head)
|
||||
})
|
||||
|
||||
test('seoFirstPageRedirect: page 1 goes to the unnumbered URL with the locale segment (L4 WR-01)', () => {
|
||||
assert.equal(seoFirstPageRedirect('/mapa-strony/posty/strona/1', 'path', 'strona', 'page'), '/mapa-strony/posty')
|
||||
assert.equal(seoFirstPageRedirect('/sitemap/posts/page/1', 'path', 'page', 'page'), '/sitemap/posts')
|
||||
assert.equal(seoFirstPageRedirect('/mapa-strony/posty?page=1', 'query', '', 'page'), '/mapa-strony/posty')
|
||||
assert.equal(seoFirstPageRedirect('/mapa-strony/posty/strona/1?x=1', 'path', 'strona', 'page'), '/mapa-strony/posty?x=1')
|
||||
})
|
||||
|
||||
test('seoFirstPageRedirect: never a redirect to the URL itself (no 301 loop)', () => {
|
||||
// the segment missing: seoPageHref falls back to the param, which the URL does not carry
|
||||
assert.equal(seoFirstPageRedirect('/mapa-strony/posty/strona/1', 'path', '', 'page'), null)
|
||||
assert.equal(seoFirstPageRedirect('/mapa-strony/posty', 'query', '', 'page'), null)
|
||||
assert.equal(seoFirstPageRedirect('/sitemap/posts', 'path', 'page', 'page'), null)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user