Description
Reminder https://developer.mozilla.org/en/docs/Web/HTML/Element/base
The HTML Base Element () specifies the base URL to use for all relative URLs contained within a document. There can be only one element in a document.
my route(s):
<Route component={Layout}>
<Route path="*" component={PageContainer} />
</Route>
I am currently using react-router (beta 3) with a <base href="/mybase/" />
and I am getting issue with the splat
params depending on how I load a page:
- during my first load of
/mybase/
, my splat is "mybase" - If I navigate to
<Link to="docs/setup">Setup</Link>
, I go correctly to/mybase/docs/setup
(which is correct according to how<base>
should help me) and mysplat
isdocs/setup
- this is good for me - If I navigate to
<Link to=".">Home</Link>
, I got assplat
the value.
. A bit weird, but it's ok too, since according to my base url, give me the right full url when doing my xhr request (I use xhr to load my data)
My main issue here is the behavior of the first time, which is reproducible by navigating to the home by bypassing the <base >
with something like this <Link to="/mybase/">Home</Link>
.
According to the <base>
doc, <Link to="/mybase/">Home</Link>
is equal to <Link to=".">Home</Link>
if base is set to /mybase/
.
But in the context of react-router, the splat
(and so probably all the routing) can be confused.
A detail that frustrate me is that splat
does not keep the slashes around the value. If I got splat to .
or /mybase/
(instead of .
and mybase/
-- without slashes) I could get my code working "as expected".
I will try to upgrade to 1.0 (not beta), but I didn't find any reference to the <base>
...
Or maybe there is just a wait to get slashes in the splat
value ?