Memory history does not support relative urls like the browser router
0xR opened this issue · comments
I discovered that the memorySource history does not support relative urls like the browser history. This is a minimal repro:
window.history.pushState(null, "", "/initial-path/oldurl");
window.history.pushState(null, "", "new/url");
const browserUrl = window.location.pathname; // /initial-path/new/url
const memorySource = createMemorySource("/initial-path/oldurl");
memorySource.history.pushState(null, "", "new/url");
const memoryUrl = memorySource.location.pathname; // new/url
codesandbox:
https://codesandbox.io/s/memory-history-relative-urls-en2s2
This means that my tests and storybook will navigate to a 404 page instead of the page that I get with the real browser history.