-
Couldn't load subscription status.
- Fork 29.7k
Add support for URL objects in Link and Router #1345
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 8 commits
87d8a31
1334cf8
2332339
846f307
a23ddc6
906ab66
32f371d
9a768e3
3df3f9d
bba0934
4b54650
3b7785c
5612fbe
0d01f5c
bd34cc7
58a4bf3
7186145
b18b1db
acf7620
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -121,11 +121,13 @@ export default class Router extends EventEmitter { | |
| } | ||
|
|
||
| push (url, as = url, options = {}) { | ||
| return this.change('pushState', url, as, options) | ||
| const formattedUrl = typeof url === 'object' ? format(url) : url | ||
| return this.change('pushState', formattedUrl, as === url ? formattedUrl : as, options) | ||
|
||
| } | ||
|
|
||
| replace (url, as = url, options = {}) { | ||
| return this.change('replaceState', url, as, options) | ||
| const formattedUrl = typeof url === 'object' ? format(url) : url | ||
| return this.change('replaceState', formattedUrl, as === url ? formattedUrl : as, options) | ||
|
||
| } | ||
|
|
||
| async change (method, url, as, options) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happen if
asis also an object. So, we need to first convert bothasandhrefinto the string version.That's easy and less error prone.
Do this in the
constructorandcomponentWillReceivePropsand save it to thethiscontext. So, we can use it efficiently from everywhere in the link.