From 964bd11cabe273bdbe4b7ecaee9d42dafb12ea82 Mon Sep 17 00:00:00 2001 From: Prajwal Manjunath Date: Wed, 19 Aug 2015 17:16:01 -0700 Subject: [PATCH] Properly handle "bytes=0-0" range header `bytes=0-0` is a valid range header used to read the first byte of a file. The old code considered it invalid. --- lib/node-static.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node-static.js b/lib/node-static.js index 6ba88ed..bbedad3 100644 --- a/lib/node-static.js +++ b/lib/node-static.js @@ -255,7 +255,7 @@ Server.prototype.parseByteRange = function(req, stat) { } /* General byte range validation */ - if (!isNaN(byteRange.from) && !!byteRange.to && 0 <= byteRange.from && byteRange.from < byteRange.to) { + if (!isNaN(byteRange.from) && !isNaN(byteRange.to) && 0 <= byteRange.from && byteRange.from <= byteRange.to) { byteRange.valid = true; } else { console.warn("Request contains invalid range header: ", rangeHeader);