AlexxNB / tinro

Highly declarative, tiny, dependency free router for Svelte's web applications.
MIT License
673 stars 30 forks source link

Nested redirects #18

Closed jnordberg closed 4 years ago

jnordberg commented 4 years ago

When in a nested route it would be handy to be able to redirect relative to the current nested route. Perhaps something like this?

<Route>
    <Route path="/">
        <p>Root</p>
    </Route>
    <Route path="/sub/*">
        <!-- this would redirect to /sub/one instead of /one  -->
        <Route path="/" relative-redirect="/one" />
        <Route path="/one">One</Route>
        <Route path="/two">Two</Route>
    </Route>
</Route>

Alternatively a redirect="one" (without the leading slash) could be treated as relative

AlexxNB commented 4 years ago

implemented in v.0.3.0

AlexxNB commented 4 years ago

<Route path="/sub/noaccess" redirect="subpage" /> will redirect to /sub/subpage.