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

jsgi/rest-store.js: wrong content-range header value returned when store is empty #32

Open
websoftix opened this issue Jul 22, 2014 · 0 comments

Comments

@websoftix
Copy link

I discovered it while working with a dgrid that uses the Pagination extension, a JsonRest store and on server side a mysql-store on an empty table.

The returned header is:
content-range: items 0--1/*

The observed effect is that dgrid displays on footer "Nan - Nan of NaN results".

The code that creates the header is on lines 117 - 118 of persvr/pintura/jsgi/rest-store.js:

var end = start + (responseValue.length || 0) - 1;
headers["content-range"] = "items " + start + '-' + end + '/' + (count || '*');

At first I though is because on line 117, when start is 0 and responseValue.length is also 0 the result in end will be -1. Even though end should be 0 it didn't caused the dgrid problem.

The problem is the * returned as the count value on 118 line because in dojo/store/JsonRest.js at line 220

return range && (range = range.match(/\/(.*)/)) && +range[1];

it is returned +(the-count-value) and +('*') is Nan.

I tested with Chrome 36 and Firefox 30 and the dgrid & dojo are last code from master.

My quick solution was to replace (count || '*') with (count || '0') in the line 117 but I'm not sure how correct that is.

Virgil

neonstalwart added a commit to neonstalwart/pintura that referenced this issue Jan 8, 2015
neonstalwart added a commit to neonstalwart/pintura that referenced this issue Jan 8, 2015
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

1 participant