react-code-dataset / next.js /packages /next /src /server /lib /router-utils /decode-path-params.test.ts
Download next.js/packages/next/src/server/lib/router-utils/decode-path-params.test.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 725 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/next.js/packages/next/src/server/lib/router-utils/decode-path-params.test.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/next.js/packages/next/src/server/lib/router-utils/decode-path-params.test.ts
-
curl -L -o decode-path-params.test.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/next.js/packages/next/src/server/lib/router-utils/decode-path-params.test.ts
725 Bytes
| /* eslint-env jest */ | |
| import { decodePathParams } from './decode-path-params' | |
| describe('decoding path params', () => { | |
| it('should decode path params', () => { | |
| const decodedPathParams = decodePathParams('sticks%20%26%20stones') | |
| expect(decodedPathParams).toBe('sticks & stones') | |
| }) | |
| it('should throw an error when the path param is improperly encoded', () => { | |
| try { | |
| // The segment %ZZ is an invalid percent-encoded sequence | |
| // because %ZZ does not represent a valid hexadecimal character. | |
| decodePathParams('sticks%ZZ%ZZ%ZZstones') | |
| } catch (error) { | |
| expect(error).toBeInstanceOf(Error) | |
| expect((error as Error).message).toBe('Failed to decode path param(s).') | |
| } | |
| }) | |
| }) | |