Middleware crashes when no query string is present
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.
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!
Running node 0.11.14. It comes back as undefined.
Thanks, Bogdan
On Dec 4, 2014, at 9:43 PM, Todd Hooper [email protected] 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.
Interesting. Thanks for that! I'll have to upgrade
xxx GET /?_escaped_fragment_= 500 3ms -
TypeError: query.hasOwnProperty is not a function
Node: 6.0
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.
meet the same problem.
node v6.2.2 "koa": "^1.2.0", "koa-prerender": "^1.0.3", "prerender-node": "^2.7.0",
I have the same problem too.
node v6.10.0 [email protected] [email protected]
please reference this fix, it's work: https://github.com/rainesinternationaldev/koa-prerender/commit/3ebc6ace0f43e405438dacdf6b518a3f3bc35502
I have the same problem "koa": "^2.5.1", "koa-prerender": "^1.0.3",
This changes will fix the issue:
https://github.com/RisingStack/koa-prerender/pull/16
Replace your line 104 in index.js: if (query && query.hasOwnProperty('_escaped_fragment_')) {
With this: if (query && query['_escaped_fragment_'] !== undefined) {