Download next.js/packages/next/src/shared/lib/router/utils/parse-relative-url.test.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 643 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/next.js/packages/next/src/shared/lib/router/utils/parse-relative-url.test.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/next.js/packages/next/src/shared/lib/router/utils/parse-relative-url.test.ts
-
curl -L -o parse-relative-url.test.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/next.js/packages/next/src/shared/lib/router/utils/parse-relative-url.test.ts
643 Bytes
| import { parseRelativeUrl } from './parse-relative-url' | |
| describe('relative urls', () => { | |
| it('should return valid pathname', () => { | |
| expect(parseRelativeUrl('/').pathname).toBe('/') | |
| expect(parseRelativeUrl('/abc').pathname).toBe('/abc') | |
| }) | |
| it('should throw for invalid pathname', () => { | |
| expect(() => parseRelativeUrl('//**y/\\')).toThrow() | |
| expect(() => parseRelativeUrl('//google.com')).toThrow() | |
| }) | |
| }) | |
| describe('query parsing', () => { | |
| it('should parse query string', () => { | |
| expect(parseRelativeUrl('/?a=1&b=2').query).toEqual({ a: '1', b: '2' }) | |
| expect(parseRelativeUrl('/').query).toEqual({}) | |
| }) | |
| }) | |