Closed C02Equinox closed 5 years ago
Same here. routes.js
import PublicIndex from './views/public/index.svelte'
import PublicLayout from './views/public/layout.svelte'
const routes = [
{
name: '/',
component: PublicIndex,
layout: PublicLayout
}
]
export { routes }
App.svelte
<script>
import { Router } from 'svelte-router-spa'
</script>
<Router />
main.js
import App from './App.svelte'
import { SpaRouter } from 'svelte-router-spa'
import { routes } from './routes'
import NotFound from './views/not_found.svelte'
SpaRouter({
routes,
pathName: document.location.pathname,
notFound: NotFound
}).getActiveRoute
const app = new App({
target: document.body
})
export default app
Hmm, I'm curious about UrlParser... It seems to be used in a way that's not supported as console.log(UrlParser('http://localhost:5000/')); provides what we need.
I've been playing around and it's almost as if the code needs to take document.location.href
and append pathName
to the end of it. I'm not a JS guy so I'll likely eventually figure it out unless someone else knows how to accomplish this.
Hi @NorseGaud & @C02Equinox:
pathName requires a full url, including the protocol and domain part.
I've updated the docs because they were wrong. Apologies if they've confused you.
If you left this param undefined it defaults to document.location.href
@NorseGaud Your pull request won't solve this issue because URLParse needs the full url as the first param and a template to parse named params as the second argument. Thanks anyway for your PR.
Thanks @jorgegorka. Changing main.js to have pathName: document.location.href
instead of document.location.pathName is confirmed to be working.
I implemented a basic app with 2 routes via the webpack starter template, started up the webpack dev server and get that error message below:
Any ideas?
In debug mode, the string passed into
new URL(urlString)
is"/"