I have an application that is configured to deploy to a customizable base path (configured at runtime not build time), which is defined on the document using <base /> and accessible via document.baseURI. Because of this, ~ loses its utility and the base router's base value is tricky-at-best.
The URL class can be used to resolve these things but, at least so far, I haven't come up with a clean way to use Wouter's current functionality to support this use case. Is there a good way to do this today?
Proposed Behavior
What I would love is to be able to do something like this:
<Router base=".">{/* resolves under the hood to (new URL(document.baseURI).pathname) */}
<Link href="/bat">Bat</Link>{/* Because this is under base=".", this becomes "./bat" -> <base>/bat */}
<Link href="~/foo">Foo</Link>{/* links to <base>/foo from anywhere */}
{/* OR, if we don't want to overload the ~ semantics: */}
<Link href="./bar">Bar</Link>{/* pretty simple: new URL("./bar", document.baseURI), leaving: -> <base>/bar */}
<Link href="~/bing">Bing</Link>{/* links to /foo from anywhere as it does today */}
I have an application that is configured to deploy to a customizable base path (configured at runtime not build time), which is defined on the document using
<base />and accessible viadocument.baseURI. Because of this,~loses its utility and the base router'sbasevalue is tricky-at-best.The
URLclass can be used to resolve these things but, at least so far, I haven't come up with a clean way to use Wouter's current functionality to support this use case. Is there a good way to do this today?Proposed Behavior
What I would love is to be able to do something like this: