[Pkg-javascript-commits] [node-mocks-http] 284/296: Make vary header de-dupe check case-insensitive

Thorsten Alteholz alteholz at moszumanska.debian.org
Mon Feb 8 18:13:45 UTC 2016


This is an automated email from the git hooks/post-receive script.

alteholz pushed a commit to branch master
in repository node-mocks-http.

commit 949e6cdbf66bb93a06afa797e9fbebaab4b47cbe
Author: Matt Hinchliffe <matt at maketea.co.uk>
Date:   Thu Nov 19 18:15:39 2015 +0000

    Make vary header de-dupe check case-insensitive
---
 lib/mockResponse.js           | 2 +-
 test/lib/mockResponse.spec.js | 6 ++++++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/lib/mockResponse.js b/lib/mockResponse.js
index 6afa763..2f21d27 100644
--- a/lib/mockResponse.js
+++ b/lib/mockResponse.js
@@ -373,7 +373,7 @@ function createResponse(options) {
         fields = Array.isArray(fields) ? fields : [ fields ];
 
         fields = fields.filter(function(field) {
-            return values.indexOf(field) === -1;
+            return !values.find(value => value.match(new RegExp(field, 'i')));
         });
 
         values = values.concat(fields);
diff --git a/test/lib/mockResponse.spec.js b/test/lib/mockResponse.spec.js
index 0bd3123..c3d4b5e 100644
--- a/test/lib/mockResponse.spec.js
+++ b/test/lib/mockResponse.spec.js
@@ -328,6 +328,12 @@ describe('mockResponse', function() {
         expect(response.get('Vary')).to.equal('value1, value2, value3');
       });
 
+      it('Should match vary header values regardless of case', function() {
+        response.vary('Value1');
+        response.vary([ 'value1', 'Value2' ]);
+        expect(response.get('Vary')).to.equal('Value1, Value2');
+      });
+
     });
 
     describe('.set()/.header()', function() {

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-mocks-http.git



More information about the Pkg-javascript-commits mailing list