http-cookie-manager
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -57,6 +57,16 @@ /** | ||
{ | ||
if (!request || !request.headers || !request.method) | ||
throw new TypeError(errors.requestMustBeIncomingMessage()) | ||
if (!request) | ||
request = { | ||
headers: { | ||
cookie: '' | ||
} | ||
} | ||
else if(!request.headers) | ||
request.headers = { | ||
cookie: '' | ||
} | ||
else if (!request.headers.cookie) | ||
request.headers.cookie = '' | ||
let cookieString = request.headers.cookie || '' | ||
let cookieString = request.headers.cookie | ||
@@ -63,0 +73,0 @@ return parseFrom(cookieString) |
@@ -64,7 +64,2 @@ 'use strict' | ||
requestMustBeIncomingMessage () | ||
{ | ||
return 'Request must be instance of IncomingMessage.' | ||
}, | ||
invalidCookieString () | ||
@@ -71,0 +66,0 @@ { |
{ | ||
"name": "http-cookie-manager", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Highly tested. Parses cookies, then stores them. Provides formatting for response header.", | ||
@@ -5,0 +5,0 @@ "main": "lib/cookie-parser.js", |
@@ -36,7 +36,21 @@ | ||
it('should throw an error if request is not an instance of IncomingMessage', function () { | ||
it('should default request if not defined', function () { | ||
expect(() => { | ||
parser.parseWith(null) | ||
}).to.throw(errors.requestMustBeIncomingMessage()) | ||
}).to.not.throw() | ||
}) | ||
it('should default headers if not defined', function () { | ||
expect(() => { | ||
parser.parseWith({}) | ||
}).to.not.throw() | ||
}) | ||
it('should default cookie string if not defined', function () { | ||
expect(() => { | ||
parser.parseWith({ | ||
headers: {} | ||
}) | ||
}).to.not.throw() | ||
}) | ||
}) | ||
@@ -43,0 +57,0 @@ |
35343
832