Skip to content
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

Middleware crashes when no query string is present #6

Open
bibanul opened this issue Dec 4, 2014 · 9 comments
Open

Middleware crashes when no query string is present #6

bibanul opened this issue Dec 4, 2014 · 9 comments

Comments

@bibanul
Copy link

bibanul commented Dec 4, 2014

Line 104:
.parse(options.url, true).query.hasOwnProperty('escaped_fragment')) {

if there's no query this .parse(options.url, true).query will evaluate to undefined and .hasOwnProperty will crash taking down the whole pipeline.

bibanul pushed a commit to bibanul/koa-prerender that referenced this issue Dec 4, 2014
gergelyke added a commit that referenced this issue Dec 5, 2014
@thoop
Copy link

thoop commented Dec 5, 2014

url.parse(options.url, true).query should not evaluate to undefined. What version of node are you running? If you run the following, do you get undefined?

Open a node repl in your terminal by typing node, then run:

require('url').parse('https://www.google.com', true).query

Can you give an example of a URL that returns undefined for query?

Thanks!

@bibanul
Copy link
Author

bibanul commented Dec 5, 2014

Running node 0.11.14. It comes back as undefined.

Thanks,
Bogdan

On Dec 4, 2014, at 9:43 PM, Todd Hooper notifications@github.com wrote:

url.parse(options.url, true).query should not evaluate to undefined. What version of node are you running? If you run the following, do you get undefined?

Open a node repl in your terminal by typing node, then run:

require('url').parse('https://www.google.com', true).query
Can you give an example of a URL that returns undefined for query?

Thanks!


Reply to this email directly or view it on GitHub.

@thoop
Copy link

thoop commented Dec 6, 2014

Interesting. Thanks for that! I'll have to upgrade

@leesiongchan
Copy link

  xxx GET /?_escaped_fragment_= 500 3ms -

  TypeError: query.hasOwnProperty is not a function

Node: 6.0

@thoop
Copy link

thoop commented May 8, 2016

Just fixed this in master of https://github.com/prerender/prerender-node

The change should be ported here to remove the hasOwnProperty use since Node v6 removed that from the querystring object.

@ghjagus
Copy link

ghjagus commented Mar 15, 2017

meet the same problem.

node v6.2.2
"koa": "^1.2.0",
"koa-prerender": "^1.0.3",
"prerender-node": "^2.7.0",

@visig9
Copy link

visig9 commented Mar 20, 2017

I have the same problem too.

node v6.10.0
koa@2.2.0
koa-prerender@1.0.3

please reference this fix, it's work:
rainesinternationaldev@3ebc6ac

@mylastore
Copy link

I have the same problem
"koa": "^2.5.1",
"koa-prerender": "^1.0.3",

@vdyachenko777
Copy link

This changes will fix the issue:

#16

Replace your line 104 in index.js: if (query && query.hasOwnProperty('_escaped_fragment_')) {
With this: if (query && query['_escaped_fragment_'] !== undefined) {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants