Skip to content

Commit c9fa654

Browse files
committed
test(proxy): add regression coverage for the non-landing path classifier
Exports isNonLandingPath and covers the exact prefix-boundary cases (e.g. /f vs /ffoo, /resume vs /resumes) that the CSP routing fix depends on, so this logic is verified by CI rather than my own ad-hoc checks.
1 parent 79d108a commit c9fa654

2 files changed

Lines changed: 37 additions & 2 deletions

File tree

apps/sim/proxy.test.ts

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ vi.mock('@/lib/core/config/env', () =>
99
createEnvMock({ NEXT_PUBLIC_APP_URL: 'https://app.sim.test' })
1010
)
1111

12-
import { resolveApiCorsPolicy } from '@/proxy'
12+
import { isNonLandingPath, resolveApiCorsPolicy } from '@/proxy'
1313

1414
function makeRequest(pathname: string, origin?: string): NextRequest {
1515
return {
@@ -122,3 +122,38 @@ describe('resolveApiCorsPolicy', () => {
122122
}
123123
})
124124
})
125+
126+
describe('isNonLandingPath', () => {
127+
it('matches known non-landing top-level pages and their subpaths', () => {
128+
const paths = [
129+
'/verify',
130+
'/sso',
131+
'/reset-password',
132+
'/resume',
133+
'/resume/workflow-123',
134+
'/f',
135+
'/f/token-abc',
136+
'/invite',
137+
'/invite/invite-id',
138+
'/playground',
139+
'/unsubscribe',
140+
]
141+
for (const path of paths) {
142+
expect(isNonLandingPath(path)).toBe(true)
143+
}
144+
})
145+
146+
it('does not match landing pages', () => {
147+
const paths = ['/', '/pricing', '/blog/some-post', '/integrations', '/terms', '/privacy']
148+
for (const path of paths) {
149+
expect(isNonLandingPath(path)).toBe(false)
150+
}
151+
})
152+
153+
it('does not false-positive on landing pages that share a prefix with a non-landing page', () => {
154+
// '/ffoo' and '/finance' start with 'f' but are not the '/f/:token' route
155+
expect(isNonLandingPath('/ffoo')).toBe(false)
156+
expect(isNonLandingPath('/finance')).toBe(false)
157+
expect(isNonLandingPath('/resumes')).toBe(false)
158+
})
159+
})

apps/sim/proxy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ const NON_LANDING_PATH_PREFIXES = [
135135
'/unsubscribe',
136136
]
137137

138-
function isNonLandingPath(pathname: string): boolean {
138+
export function isNonLandingPath(pathname: string): boolean {
139139
return NON_LANDING_PATH_PREFIXES.some(
140140
(prefix) => pathname === prefix || pathname.startsWith(`${prefix}/`)
141141
)

0 commit comments

Comments
 (0)