Skip to content

Commit

Permalink
test: url parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
posva committed Dec 5, 2024
1 parent 731c9ee commit d1dba9c
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions packages/router/__tests__/location.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,24 @@ describe('parseURL', () => {
hash: '#hash',
query: {},
})
expect(parseURL('/foo#hash')).toEqual({
fullPath: '/foo#hash',
path: '/foo',
hash: '#hash',
query: {},
})
expect(parseURL('/foo?')).toEqual({
fullPath: '/foo?',
path: '/foo',
hash: '',
query: {},
})
expect(parseURL('/foo')).toEqual({
fullPath: '/foo',
path: '/foo',
hash: '',
query: {},
})
})

it('works with empty hash', () => {
Expand All @@ -177,6 +189,12 @@ describe('parseURL', () => {
hash: '#',
query: {},
})
expect(parseURL('/foo')).toEqual({
fullPath: '/foo',
path: '/foo',
hash: '',
query: {},
})
})

it('works with a relative paths', () => {
Expand All @@ -198,7 +216,20 @@ describe('parseURL', () => {
hash: '',
query: {},
})
// cannot go below root
expect(parseURL('../../foo', '/parent/bar')).toEqual({
fullPath: '/foo',
path: '/foo',
hash: '',
query: {},
})

expect(parseURL('', '/parent/bar')).toEqual({
fullPath: '/parent/bar',
path: '/parent/bar',
hash: '',
query: {},
})
expect(parseURL('#foo', '/parent/bar')).toEqual({
fullPath: '/parent/bar#foo',
path: '/parent/bar',
Expand Down

0 comments on commit d1dba9c

Please sign in to comment.