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
93424b64
Unverified
Commit
93424b64
authored
Dec 10, 2018
by
Tim Neutkens
Committed by
GitHub
Dec 10, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use correct default for query (#5851)
parent
6b7864e5
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
13 additions
and
4 deletions
+13
-4
next-server.ts
packages/next-server/server/next-server.ts
+4
-4
no-query.js
test/integration/custom-server/pages/no-query.js
+1
-0
server.js
test/integration/custom-server/server.js
+4
-0
index.test.js
test/integration/custom-server/test/index.test.js
+4
-0
No files found.
packages/next-server/server/next-server.ts
View file @
93424b64
...
...
@@ -205,7 +205,7 @@ export default class Server {
return
sendHTML
(
req
,
res
,
html
,
{
generateEtags
})
}
public
async
render
(
req
:
IncomingMessage
,
res
:
ServerResponse
,
pathname
:
string
,
query
:
ParsedUrlQuery
,
parsedUrl
:
UrlWithParsedQuery
):
Promise
<
void
>
{
public
async
render
(
req
:
IncomingMessage
,
res
:
ServerResponse
,
pathname
:
string
,
query
:
ParsedUrlQuery
=
{},
parsedUrl
?
:
UrlWithParsedQuery
):
Promise
<
void
>
{
const
url
:
any
=
req
.
url
if
(
isInternalUrl
(
url
))
{
return
this
.
handleRequest
(
req
,
res
,
parsedUrl
)
...
...
@@ -227,7 +227,7 @@ export default class Server {
return
this
.
sendHTML
(
req
,
res
,
html
)
}
public
async
renderToHTML
(
req
:
IncomingMessage
,
res
:
ServerResponse
,
pathname
:
string
,
query
:
ParsedUrlQuery
):
Promise
<
string
|
null
>
{
public
async
renderToHTML
(
req
:
IncomingMessage
,
res
:
ServerResponse
,
pathname
:
string
,
query
:
ParsedUrlQuery
=
{}
):
Promise
<
string
|
null
>
{
try
{
// To make sure the try/catch is executed
const
html
=
await
renderToHTML
(
req
,
res
,
pathname
,
query
,
this
.
renderOpts
)
...
...
@@ -243,13 +243,13 @@ export default class Server {
}
}
public
async
renderError
(
err
:
Error
|
null
,
req
:
IncomingMessage
,
res
:
ServerResponse
,
pathname
:
string
,
query
:
ParsedUrlQuery
):
Promise
<
void
>
{
public
async
renderError
(
err
:
Error
|
null
,
req
:
IncomingMessage
,
res
:
ServerResponse
,
pathname
:
string
,
query
:
ParsedUrlQuery
=
{}
):
Promise
<
void
>
{
res
.
setHeader
(
'Cache-Control'
,
'no-cache, no-store, max-age=0, must-revalidate'
)
const
html
=
await
this
.
renderErrorToHTML
(
err
,
req
,
res
,
pathname
,
query
)
return
this
.
sendHTML
(
req
,
res
,
html
)
}
public
async
renderErrorToHTML
(
err
:
Error
|
null
,
req
:
IncomingMessage
,
res
:
ServerResponse
,
pathname
:
string
,
query
:
ParsedUrlQuery
)
{
public
async
renderErrorToHTML
(
err
:
Error
|
null
,
req
:
IncomingMessage
,
res
:
ServerResponse
,
pathname
:
string
,
query
:
ParsedUrlQuery
=
{}
)
{
return
renderErrorToHTML
(
err
,
req
,
res
,
pathname
,
query
,
this
.
renderOpts
)
}
...
...
test/integration/custom-server/pages/no-query.js
0 → 100644
View file @
93424b64
export
default
()
=>
'test'
test/integration/custom-server/server.js
View file @
93424b64
...
...
@@ -10,6 +10,10 @@ const handleNextRequests = app.getRequestHandler()
app
.
prepare
().
then
(()
=>
{
const
server
=
new
http
.
Server
((
req
,
res
)
=>
{
if
(
req
.
url
===
'/no-query'
)
{
return
app
.
render
(
req
,
res
,
'/no-query'
)
}
if
(
/setAssetPrefix/
.
test
(
req
.
url
))
{
app
.
setAssetPrefix
(
`http://127.0.0.1:
${
port
}
`
)
}
else
if
(
/setEmptyAssetPrefix/
.
test
(
req
.
url
))
{
...
...
test/integration/custom-server/test/index.test.js
View file @
93424b64
...
...
@@ -37,6 +37,10 @@ describe('Custom Server', () => {
beforeAll
(()
=>
startServer
())
afterAll
(()
=>
killApp
(
server
))
it
(
'should handle render with undefined query'
,
async
()
=>
{
expect
(
await
renderViaHTTP
(
appPort
,
'/no-query'
)).
toMatch
(
/"query":/
)
})
it
(
'should set the assetPrefix dynamically'
,
async
()
=>
{
const
normalUsage
=
await
renderViaHTTP
(
appPort
,
'/asset'
)
expect
(
normalUsage
).
not
.
toMatch
(
/127
\.
0
\.
0
\.
1/
)
...
...
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