Skip to content

Commit 4f78e11

Browse files
committed
test: cover userinfo and file:// in changeLocation
1 parent 571634c commit 4f78e11

1 file changed

Lines changed: 21 additions & 1 deletion

File tree

packages/router/__tests__/history/html5.spec.ts

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ describe('History HTMl5', () => {
9393
expect(spy).toHaveBeenCalledWith(
9494
expect.anything(),
9595
expect.any(String),
96-
'http://localhost:3000/foo'
96+
'/foo'
9797
)
9898
history.push('//foo')
9999
expect(spy).toHaveBeenLastCalledWith(
@@ -104,6 +104,26 @@ describe('History HTMl5', () => {
104104
spy.mockRestore()
105105
})
106106

107+
it('passes a relative URL when document URL contains userinfo', () => {
108+
getWindow().happyDOM.setURL('http://test:test@localhost:3000/')
109+
const spy = vi.spyOn(window.history, 'replaceState')
110+
createWebHistory()
111+
expect(spy).toHaveBeenCalledWith(expect.anything(), expect.any(String), '/')
112+
spy.mockRestore()
113+
})
114+
115+
it('prepends the file:// origin on file documents without a hash base', () => {
116+
getWindow().happyDOM.setURL('file:///app/index.html')
117+
const spy = vi.spyOn(window.history, 'replaceState')
118+
createWebHistory()
119+
expect(spy).toHaveBeenCalledWith(
120+
expect.anything(),
121+
expect.any(String),
122+
'file:///app/index.html'
123+
)
124+
spy.mockRestore()
125+
})
126+
107127
describe('specific to base containing a hash', () => {
108128
it('calls push with hash part of the url with a base', () => {
109129
getWindow().happyDOM.setURL('file:///usr/etc/index.html')

0 commit comments

Comments
 (0)