Skip to content

Instantly share code, notes, and snippets.

@dvv
Created May 3, 2010 20:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dvv/388542 to your computer and use it in GitHub Desktop.
Save dvv/388542 to your computer and use it in GitHub Desktop.
--- rest-store.js.orig 2010-05-04 18:59:11.000000000 +0400
+++ rest-store.js 2010-05-04 01:08:07.000000000 +0400
@@ -63,19 +63,19 @@
else if(!METHOD_HAS_BODY[method]){
if(method === "get" && request.pathInfo.substring(request.pathInfo.length - 1) === "/"){
// handle the range header
- if(metadata.range){
- // invalid "Range:" just results in 0-Infinity
+ if (metadata.range) {
+ // invalid "Range:" are ignored
+ var r = false;
metadata.range.replace(/^items=(\d+)-(\d+)?/, function(s, b, e){
- if(b >= 0){
- metadata.start = b;
- }
- if(e >= b){
- metadata.end = e;
- }
- else if (e !== undefined){
+ metadata.start = +b;
+ if (+e >= b) {
+ metadata.end = +e;
+ r = true;
+ } else if (e !== undefined) {
delete metadata.start;
}
});
+ if (!r) delete metadata.range;
}
// queries are not decoded, the info needs to be retained for parsing
// TODO: limit the range by a configurable number
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment