Skip to content
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,10 @@ export default class Server {

getRequestHandler () {
return (req, res, parsedUrl) => {
if (!parsedUrl) {
if (!parsedUrl || parsedUrl && !parsedUrl.query) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this simplifies to if (!parsedUrl || !parsedUrl.query)

Copy link
Member Author

@timneutkens timneutkens Feb 26, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sedubois since it's an or both sides of the expression are executed. In this case when parsedUrl is undefined it will throw an query is not defined error. That's why we have to check if parsedUrl exists 👍 If this was && you would be totally right 😄

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok sorry I meant this should probably work: if (!(parsedUrl && parsedUrl.query)). But anyways not super important...

parsedUrl = parse(req.url, true)
}

if (!parsedUrl.query) {
throw new Error('Please provide a parsed url to `handle` as third parameter. See https://github.com/zeit/next.js#custom-server-and-routing for an example.')
}

return this.run(req, res, parsedUrl)
.catch((err) => {
if (!this.quiet) console.error(err)
Expand Down