From d1dba9c6da88da9e24b2895827a0adf3fc14d991 Mon Sep 17 00:00:00 2001 From: Eduardo San Martin Morote Date: Thu, 5 Dec 2024 11:24:40 +0100 Subject: [PATCH] test: url parsing --- packages/router/__tests__/location.spec.ts | 31 ++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/packages/router/__tests__/location.spec.ts b/packages/router/__tests__/location.spec.ts index 0511ad89f..7b7497687 100644 --- a/packages/router/__tests__/location.spec.ts +++ b/packages/router/__tests__/location.spec.ts @@ -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', () => { @@ -177,6 +189,12 @@ describe('parseURL', () => { hash: '#', query: {}, }) + expect(parseURL('/foo')).toEqual({ + fullPath: '/foo', + path: '/foo', + hash: '', + query: {}, + }) }) it('works with a relative paths', () => { @@ -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',