Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
437140a0
Unverified
Commit
437140a0
authored
Jul 10, 2019
by
Joe Haddad
Committed by
GitHub
Jul 10, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add UrlObject to router methods (#7859)
parent
1d8fa3a9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
9 deletions
+7
-9
router.ts
packages/next-server/lib/router/router.ts
+6
-9
hello.tsx
test/integration/typescript/pages/hello.tsx
+1
-0
No files found.
packages/next-server/lib/router/router.ts
View file @
437140a0
...
...
@@ -2,7 +2,7 @@
// tslint:disable:no-console
import
{
ParsedUrlQuery
}
from
'querystring'
import
{
ComponentType
}
from
'react'
import
{
parse
}
from
'url'
import
{
parse
,
UrlObject
}
from
'url'
import
mitt
,
{
MittEmitter
}
from
'../mitt'
import
{
...
...
@@ -21,6 +21,8 @@ function toRoute(path: string): string {
return
path
.
replace
(
/
\/
$/
,
''
)
||
'/'
}
type
Url
=
UrlObject
|
string
export
type
BaseRouter
=
{
route
:
string
pathname
:
string
...
...
@@ -211,7 +213,7 @@ export default class Router implements BaseRouter {
* @param as masks `url` for the browser
* @param options object you can define `shallow` and other options
*/
push
(
url
:
string
,
as
:
string
=
url
,
options
=
{})
{
push
(
url
:
Url
,
as
:
Url
=
url
,
options
=
{})
{
return
this
.
change
(
'pushState'
,
url
,
as
,
options
)
}
...
...
@@ -221,16 +223,11 @@ export default class Router implements BaseRouter {
* @param as masks `url` for the browser
* @param options object you can define `shallow` and other options
*/
replace
(
url
:
string
,
as
:
string
=
url
,
options
=
{})
{
replace
(
url
:
Url
,
as
:
Url
=
url
,
options
=
{})
{
return
this
.
change
(
'replaceState'
,
url
,
as
,
options
)
}
change
(
method
:
string
,
_url
:
string
,
_as
:
string
,
options
:
any
):
Promise
<
boolean
>
{
change
(
method
:
string
,
_url
:
Url
,
_as
:
Url
,
options
:
any
):
Promise
<
boolean
>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
// If url and as provided as an object representation,
// we'll format them into the string version here.
...
...
test/integration/typescript/pages/hello.tsx
View file @
437140a0
...
...
@@ -3,6 +3,7 @@ import { hello } from '../components/hello'
import
{
World
}
from
'../components/world'
export
default
function
HelloPage
():
JSX
.
Element
{
// TEST: verify process.browser extension works
console
.
log
(
process
.
browser
)
return
(
<
div
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment