History: Feature request: Support relative paths in history.push

Created on 11 Feb 2017  路  4Comments  路  Source: ReactTraining/history

Hi! Do you think that would make sense to support relative paths in history.push? So we can do stuff like that:

browserHistory.push('../'); // go to parent
browserHistory.push('../sibling'); // go to sibling

Most helpful comment

I have a question related to relative path

When I call browserHistory.push('posts')
path e.g. /user/1 goes to /user/posts
path /user/1/ goes to /user/1/posts

It was unexpected to me at first, but then I supposed it might be the correct behavior
Is there a config to always append a trailing slash? Or a way to go to the deeper level from the first path?
In general what would you recommend?

I'm using universal-router, and currently trailing slash doesn't matter in my routes, so /user/1 and /user/1/ resolve to the same page

All 4 comments

You'll be happy to know that we already do support relative pathnames :)

If you're not seeing this you may be using an older version.

Looks like we are on outdated version.

We use RR 2.5.3 which uses history ^2.0.1 and there's no LocationUtils there. Looks like there's no way we can get this in v2: v2.8.2 uses history 2.1.2.

Thank you!

I have a question related to relative path

When I call browserHistory.push('posts')
path e.g. /user/1 goes to /user/posts
path /user/1/ goes to /user/1/posts

It was unexpected to me at first, but then I supposed it might be the correct behavior
Is there a config to always append a trailing slash? Or a way to go to the deeper level from the first path?
In general what would you recommend?

I'm using universal-router, and currently trailing slash doesn't matter in my routes, so /user/1 and /user/1/ resolve to the same page

Same issue as @quanganhtran

Was this page helpful?
0 / 5 - 0 ratings

Related issues

vchibilisco-convey picture vchibilisco-convey  路  3Comments

andi5 picture andi5  路  6Comments

govizlora picture govizlora  路  5Comments

clayrisser picture clayrisser  路  4Comments

johnjesse picture johnjesse  路  6Comments