pshrmn / curi

A JavaScript router for single-page applications
https://curi.js.org
MIT License
269 stars 10 forks source link

router.url with no name returns relative URL #204

Closed pshrmn closed 5 years ago

pshrmn commented 5 years ago

When using router.url with no name property, the URL returned will have no pathname component. If the history is configured with a base, that will not be included either.

const url = router.url({ hash: "comments" });
// url = "#comments"

When navigating using a URL with no pathname component, the corresponding location will re-use the current location's pathname.

const router = createRouter(inMemory, routes, {
  history: {
    locations: [{ url: "/initial-location" }]
  }
});
const url = router.url({ hash: "comments" });
router.navigate({ url });
const { response } = router.current();
// response.location = { pathname: "/initial-location", hash: "comments", ... }