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
e6fb48ce
Unverified
Commit
e6fb48ce
authored
May 20, 2019
by
JJ Kasper
Committed by
GitHub
May 20, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix string type on router.query (#7387)
parent
dc1f907c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
5 deletions
+6
-5
router.ts
packages/next-server/lib/router/router.ts
+4
-3
render.tsx
packages/next-server/server/render.tsx
+2
-2
No files found.
packages/next-server/lib/router/router.ts
View file @
e6fb48ce
...
...
@@ -5,6 +5,7 @@ import { parse } from 'url';
import
mitt
,
{
MittEmitter
}
from
'../mitt'
;
import
{
formatWithValidation
,
getURL
,
loadGetInitialProps
,
NextPageContext
,
AppContextType
}
from
'../utils'
;
import
{
rewriteUrlForNextExport
}
from
'./rewrite-url-for-export'
import
{
ParsedUrlQuery
}
from
'querystring'
;
function
toRoute
(
path
:
string
):
string
{
return
path
.
replace
(
/
\/
$/
,
''
)
||
'/'
...
...
@@ -13,7 +14,7 @@ function toRoute(path: string): string {
export
type
BaseRouter
=
{
route
:
string
pathname
:
string
query
:
string
query
:
ParsedUrlQuery
asPath
:
string
,
}
...
...
@@ -31,7 +32,7 @@ type BeforePopStateCallback = (state: any) => boolean
export
default
class
Router
implements
BaseRouter
{
route
:
string
pathname
:
string
query
:
string
query
:
ParsedUrlQuery
asPath
:
string
components
:
{[
pathname
:
string
]:
RouteInfo
}
subscriptions
:
Set
<
Subscription
>
...
...
@@ -41,7 +42,7 @@ export default class Router implements BaseRouter {
static
events
:
MittEmitter
=
mitt
()
constructor
(
pathname
:
string
,
query
:
an
y
,
as
:
string
,
{
initialProps
,
pageLoader
,
App
,
Component
,
err
}:
{
initialProps
:
any
,
pageLoader
:
any
,
Component
:
ComponentType
,
App
:
ComponentType
,
err
?:
Error
})
{
constructor
(
pathname
:
string
,
query
:
ParsedUrlQuer
y
,
as
:
string
,
{
initialProps
,
pageLoader
,
App
,
Component
,
err
}:
{
initialProps
:
any
,
pageLoader
:
any
,
Component
:
ComponentType
,
App
:
ComponentType
,
err
?:
Error
})
{
// represents the current component key
this
.
route
=
toRoute
(
pathname
)
...
...
packages/next-server/server/render.tsx
View file @
e6fb48ce
...
...
@@ -31,12 +31,12 @@ function noRouter() {
class
ServerRouter
implements
BaseRouter
{
route
:
string
pathname
:
string
query
:
string
query
:
ParsedUrlQuery
asPath
:
string
// TODO: Remove in the next major version, as this would mean the user is adding event listeners in server-side `render` method
static
events
:
MittEmitter
=
mitt
()
constructor
(
pathname
:
string
,
query
:
an
y
,
as
:
string
)
{
constructor
(
pathname
:
string
,
query
:
ParsedUrlQuer
y
,
as
:
string
)
{
this
.
route
=
pathname
.
replace
(
/
\/
$/
,
''
)
||
'/'
this
.
pathname
=
pathname
this
.
query
=
query
...
...
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