cookiejar
Advanced tools
Comparing version 1.3.0 to 1.3.1
@@ -1,2 +0,2 @@ | ||
exports.CookieAccessInfo=CookieAccessInfo=function CookieAccessInfo(domain,path,secure,script) { | ||
var CookieAccessInfo=exports.CookieAccessInfo=function CookieAccessInfo(domain,path,secure,script) { | ||
if(this instanceof CookieAccessInfo) { | ||
@@ -14,3 +14,3 @@ this.domain=domain||undefined; | ||
exports.Cookie=Cookie=function Cookie(cookiestr) { | ||
var Cookie=exports.Cookie=function Cookie(cookiestr) { | ||
if(cookiestr instanceof Cookie) { | ||
@@ -29,3 +29,5 @@ return cookiestr; | ||
if(cookiestr) { | ||
this.parse(cookiestr) | ||
try { | ||
this.parse(cookiestr) | ||
} catch(e) {} | ||
} | ||
@@ -65,3 +67,3 @@ return this; | ||
if(this instanceof Cookie) { | ||
var parts=str.split(";") | ||
var parts=str.split(";").filter(function(value){return !!value}) | ||
, pair=parts[0].match(/([^=]+)=((?:.|\n)*)/) | ||
@@ -139,3 +141,3 @@ , key=pair[1] | ||
exports.CookieJar=CookieJar=function CookieJar() { | ||
var CookieJar=exports.CookieJar=function CookieJar() { | ||
if(this instanceof CookieJar) { | ||
@@ -181,2 +183,3 @@ var cookies = {} //name: [Cookie] | ||
var cookies_list = cookies[cookie_name]; | ||
if (!cookies_list) return; | ||
for(var i=0;i<cookies_list.length;i++) { | ||
@@ -215,3 +218,3 @@ var cookie = cookies_list[i]; | ||
//returns list of cookies that were set correctly | ||
//returns list of cookies that were set correctly. Cookies that are expired and removed are not returned. | ||
CookieJar.prototype.setCookies = function setCookies(cookies) { | ||
@@ -218,0 +221,0 @@ cookies=Array.isArray(cookies) |
{ "name" : "cookiejar" | ||
, "version" : "1.3.0" | ||
, "version" : "1.3.1" | ||
, "author": "bradleymeck" | ||
, "main": "cookiejar.js" | ||
, "description" : "simple persistent cookiejar system" | ||
, "license": "MIT" | ||
, "repository": {"type": "git", "url": "https://github.com/bmeck/node-cookiejar.git"} | ||
} |
@@ -6,27 +6,46 @@ var Cookie=require("../cookiejar") | ||
var assert = require('assert'); | ||
// Test Cookie | ||
var cookie = new Cookie("a=1;domain=.test.com;path=/"); | ||
assert.equal(cookie.name, "a"); | ||
assert.equal(cookie.value, "1"); | ||
assert.equal(cookie.domain, ".test.com"); | ||
assert.equal(cookie.path, "/"); | ||
assert.equal(cookie.secure, false); | ||
assert.equal(cookie.expiration_date, Infinity); | ||
assert.deepEqual(cookie, new Cookie("a=1;domain=.test.com;path=/")); | ||
assert.ok(cookie.collidesWith(new Cookie("a=1;domain=.test.com;path=/"))); | ||
// Test CookieJar | ||
var test_jar = CookieJar(); | ||
test_jar.setCookies( | ||
"a=1;domain=.test.com;path=/" | ||
+":b=2;domain=test.com;path=/" | ||
+":c=3;domain=test.com;path=/;expires=January 1, 1970"); | ||
"a=1;domain=.test.com;path=/" | ||
+":b=2;domain=test.com;path=/" | ||
+":c=3;domain=test.com;path=/;expires=January 1, 1970"); | ||
var cookies=test_jar.getCookies(CookieAccessInfo("test.com","/")) | ||
console.log( | ||
cookies.length==2 | ||
|| "Expires on setCookies fail"+cookies.length+"\n"+cookies.toString()); | ||
console.log( | ||
cookies.toValueString() == 'a=1;b=2' | ||
|| "Cannot get value string of multiple cookies"); | ||
assert.equal(cookies.length, 2, "Expires on setCookies fail\n" + cookies.toString()); | ||
assert.equal(cookies.toValueString(), 'a=1;b=2', "Cannot get value string of multiple cookies"); | ||
cookies=test_jar.getCookies(CookieAccessInfo("www.test.com","/")) | ||
console.log( | ||
cookies.length==1 | ||
|| "Wildcard domain fail"+cookies.length+"\n"+cookies.toString()); | ||
assert.equal(cookies.length, 1, "Wildcard domain fail\n" + cookies.toString()); | ||
test_jar.setCookies("b=2;domain=test.com;path=/;expires=January 1, 1970"); | ||
cookies=test_jar.getCookies(CookieAccessInfo("test.com","/")) | ||
console.log( | ||
cookies.length==1 | ||
|| "Delete cookie fail"+cookies.length+"\n"+cookies.toString()); | ||
console.log(String(test_jar.getCookies(CookieAccessInfo("test.com","/")))) | ||
assert.equal(cookies.length, 1, "Delete cookie fail\n" + cookies.toString()); | ||
assert.equal(String(test_jar.getCookies(CookieAccessInfo("test.com","/"))), "a=1; domain=.test.com; path=/"); | ||
cookie=Cookie("a=1;domain=test.com;path=/;HttpOnly"); | ||
console.log(cookie.noscript || "HttpOnly flag parsing failed\n"+cookie.toString()); | ||
assert.ok(cookie.noscript, "HttpOnly flag parsing failed\n" + cookie.toString()); | ||
var test_jar = CookieJar(); | ||
test_jar.setCookies([ | ||
"a=1;domain=.test.com;path=/" | ||
, "a=1;domain=.test.com;path=/" | ||
, "a=2;domain=.test.com;path=/" | ||
, "b=3;domain=.test.com;path=/"]); | ||
var cookies=test_jar.getCookies(CookieAccessInfo("test.com","/")) | ||
assert.equal(cookies.length, 2); | ||
assert.equal(cookies[0].value, 2); |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Non-existent author
Supply chain riskThe package was published by an npm account that no longer exists.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No License Found
License(Experimental) License information could not be found
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
11058
5
0
254
0
1
0
0
1