Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions src/constants/__tests__/seo-route-policy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,15 @@ describe('SEO route policy', () => {
expect(receivesNoindexHeader(route)).toBe(false)
})

it.each(['/home', '/home/activity', '/invite?code=abc&lid=campaign', '/api/og?type=send&username=alice&amount=10'])(
'renders a noindex header for %s through Next route matching',
async (route) => {
await expect(renderedRobotsHeader(route)).resolves.toBe('noindex, nofollow')
}
)
it.each([
'/home',
'/home/activity',
'/invite?code=abc&lid=campaign',
'/invite?invited_by=abc',
'/api/og?type=send&username=alice&amount=10',
])('renders a noindex header for %s through Next route matching', async (route) => {
await expect(renderedRobotsHeader(route)).resolves.toBe('noindex, nofollow')
})

it.each(['/lp', '/api/og/marketing?title=Peanut', '/m/stain', '/en/pay-with/pix'])(
'does not render a noindex header for %s through Next route matching',
Expand Down Expand Up @@ -107,6 +110,7 @@ describe('SEO route policy', () => {
'/setup$',
'/invite$',
'/invite?code=',
'/invite?invited_by=',
])
})
})
4 changes: 3 additions & 1 deletion src/constants/seo-route-policy.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ const ROBOTS_DISALLOWED_PATHS = Object.freeze([
'/withdraw',
])

// GSC shows these exact shells (or their invite query variants) in Google's
// GSC shows these exact shells (or their invite query variants — ?invited_by=
// is what peanut-ui emits since ui#2828, ?code= the legacy alias) in Google's
// index. They need a narrow crawl exception so search engines can observe and
// refresh the X-Robots-Tag. Descendant transaction/profile URLs remain
// blocked. Keep the exceptions while these routes exist; only remove one once
Expand All @@ -89,6 +90,7 @@ const GOOGLE_DEINDEX_CRAWL_ALLOW_PATHS = Object.freeze([
'/setup$',
'/invite$',
'/invite?code=',
'/invite?invited_by=',
])

const NOINDEX_HEADER = Object.freeze({ key: 'X-Robots-Tag', value: 'noindex, nofollow' })
Expand Down
Loading