Skip to content

Avoiding to send empty q parameters #1

Merged
merged 1 commit into from Dec 6, 2013

3 participants

@rudyrigot

No description provided.

@guillaumebort guillaumebort merged commit 6c4e89c into prismicio:master Dec 6, 2013
@sadache sadache commented on the diff Dec 6, 2013
routes/blog.js
@@ -15,7 +15,11 @@ exports.posts = prismic.route(function(req, res, ctx) {
var category = req.params['category'];
- ctx.api.form('blog').ref(ctx.ref).query(category ? '[[:d = at(my.blog-post.category, "' + category + '")]]' : '').submit(function(posts) {
+ var searchForm = ctx.api.form('blog').ref(ctx.ref);
+
+ if (category) searchForm.query('[[:d = at(my.blog-post.category, "' + category + '")]]');
@sadache
sadache added a note Dec 6, 2013

how is that different?

@rudyrigot
rudyrigot added a note Dec 6, 2013

On the homepage of the blog, there is no category, therefore, a .query('') was called, which crashed and halted the node.js server.

Now, on the blog homepage, the query method is never called, since there's nothing to query about anyway; it is only called when needed, in the blog category pages.

Just talked with Guillaume, he advised me to also handle it in the JS dev kit (no adding a q parameter if query is called on an empty string), I'll do it today.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.