Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

simple-cookie

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

simple-cookie - npm Package Compare versions

Comparing version 0.0.5 to 0.0.6

19

index.js

@@ -23,3 +23,4 @@ function printExpires(expires){

parse: function( string, path, domain ){
var s = string.replace(/;\s+/,';').split(';').map(function(s){return s.split('=');});
var s = string.replace(/;\s+/g,';').split(';')
.map(function(s){return s.replace(/\s+\=\s+/g,'=').split('=');});

@@ -30,6 +31,10 @@ var n = s.shift();

obj.expires = false;
obj.httponly = false;
obj.secure = false;
obj.path = path || '/';
obj.domain = domain || '';
var I, f = {
'httponly': function(v){ obj.httponly = true },
'secure': function(v){ obj.secure = true },
'httponly': function(){ obj.httponly = true },
'secure': function(){ obj.secure = true },
'expires': function(v){ obj.expires = new Date(v) },

@@ -43,10 +48,6 @@ 'max-age': function(v){ if(obj.expires) return; obj.expires = new Date((new Date()).valueOf()+(v*1000)) },

I = s[i][0].toLowerCase();
if( typeof f[I] != 'undefined' ) f[I]( s[i][1] );
if( typeof f[I] != 'undefined' ) f[I]( s[i].length==2 ? s[i][1] : '' );
}
if( typeof obj.httponly == 'undefined' ) obj.httponly = false;
if( typeof obj.secure == 'undefined' ) obj.secure = false;
if( typeof obj.path == 'undefined' ) obj.path = path || '/';
if( typeof obj.domain == 'undefined' ) obj.domain = domain || '';
if( typeof obj.expires == 'undefined' || !obj.expires ) obj.expires = 0;
if( !obj.expires ) obj.expires = 0;
obj.name = n[0];

@@ -53,0 +54,0 @@ obj.value = decodeURIComponent(n[1]);

{
"name": "simple-cookie",
"version": "0.0.5",
"version": "0.0.6",
"description": "Simple cookie parser & serializer",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -11,2 +11,3 @@

var co;
var date = (new Date((new Date()).valueOf() + 3000)).toGMTString();

@@ -40,2 +41,21 @@ describe('simple-cookie',function(){

describe('#parseString',function(){
it("should return the right object from cookie string",function(){
var theCookie = 'cnameSecure=cval1sec; expires='+date+
'; domain=.example.com; path=/; secure';
var h = cookie.parse( theCookie, 'example.com', '/is/cool' );
h.name.should.equal( 'cnameSecure' );
h.value.should.equal( 'cval1sec' );
h.expires.should.be.a( 'date' );
h.expires.toGMTString().should.equal( date );
h.secure.should.equal( true );
h.httponly.should.equal( false );
h.path.should.equal( '/' );
h.domain.should.equal( '.example.com' );
});
});
describe('#tokeninze',function(){

@@ -52,3 +72,2 @@ it('should return tokenized cookies ready to send', function(){

var h = cookie.tokenize(cc);
console.log(h);
h.should.be.a('string');

@@ -55,0 +74,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc