Feature Request: Support document.baseURI resolution
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 7.9k
- Forks
- 190
- Avg merge
- 12h 50m
- Merged PRs (30d)
- 3
Description
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 */}
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the Router and Link entry points and the existing handling of the base value and hrefs. Compare the proposed relative, document.baseURI-based resolution with the current ~ behavior, then run the existing test suite to identify routing cases that need coverage. Done means customizable document base paths resolve consistently without breaking current links.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- frontend, web-dev
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100