ef2b8f8696
The `pathname` in app-render was actually "page" (e.g. `/blog/[slug]`), with special url conventions. Instead we should use actual request url as pathname. Rename previous `pathname` arg to `pagePath` for better readability Also improved the url validation
13 lines
405 B
TypeScript
13 lines
405 B
TypeScript
import { validateURL } from 'next/dist/server/app-render/validate-url'
|
|
|
|
describe('validateUrl', () => {
|
|
it('should return valid pathname', () => {
|
|
expect(validateURL('/')).toBe('/')
|
|
expect(validateURL('/abc')).toBe('/abc')
|
|
})
|
|
|
|
it('should throw for invalid pathname', () => {
|
|
expect(() => validateURL('//**y/\\')).toThrow()
|
|
expect(() => validateURL('//google.com')).toThrow()
|
|
})
|
|
})
|