]> git.ipfire.org Git - thirdparty/vuejs/router.git/commitdiff
test: url parsing
authorEduardo San Martin Morote <posva13@gmail.com>
Thu, 5 Dec 2024 10:24:40 +0000 (11:24 +0100)
committerEduardo San Martin Morote <posva13@gmail.com>
Thu, 5 Dec 2024 10:24:40 +0000 (11:24 +0100)
packages/router/__tests__/location.spec.ts

index 0511ad89ff28bb30ee94ebe2954b045bc19f5c53..7b7497687d1ed456b91ee4beba59e75cf603e17a 100644 (file)
@@ -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',