silverwolf-x/project / packages /next /src /shared /lib /router /utils /parse-relative-url.test.ts
silverwolf-x's picture
download
raw
737 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')
expect(parseRelativeUrl('//**y/\\').pathname).toBe('//**y//')
expect(parseRelativeUrl('//google.com').pathname).toBe('//google.com')
})
it('should throw for invalid pathname', () => {
expect(() => parseRelativeUrl('http://example.com/abc')).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({})
})
})

Xet Storage Details

Size:
737 Bytes
·
Xet hash:
d3a9dda86e037f55230c73d4e403eae3504a1399de8f21178139b88c9dc7c961

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.