From e22f0e267809e1fc65d9b41ee45853110db02fcc Mon Sep 17 00:00:00 2001
From: Klaus Hartl
Date: Fri, 25 Jan 2013 18:58:42 +0100
Subject: [PATCH 01/96] Remove trailing whitespace
---
jquery.cookie.js | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/jquery.cookie.js b/jquery.cookie.js
index 9fee964..8493d86 100644
--- a/jquery.cookie.js
+++ b/jquery.cookie.js
@@ -16,7 +16,7 @@
function decoded(s) {
return unRfc2068(decodeURIComponent(s.replace(pluses, ' ')));
}
-
+
function unRfc2068(value) {
if (value.indexOf('"') === 0) {
// This is a quoted cookie as according to RFC2068, unescape
@@ -59,16 +59,16 @@
var parts = cookies[i].split('=');
var name = decode(parts.shift());
var cookie = decode(parts.join('='));
-
+
if (config.json) {
cookie = JSON.parse(cookie);
}
-
+
if (key && key === name) {
result = cookie;
break;
}
-
+
if (!key) {
result[name] = cookie;
}
From 40b8755b982f922887e72fc3a9f3f5ec227b35f3 Mon Sep 17 00:00:00 2001
From: Klaus Hartl
Date: Fri, 25 Jan 2013 19:30:17 +0100
Subject: [PATCH 02/96] Moving all test related files to /test
---
README.md | 4 ++--
grunt.js | 2 +-
test.html => test/index.html | 4 ++--
sandbox.html => test/sandbox.html | 0
server.js => test/server.js | 2 +-
test.js => test/tests.js | 0
6 files changed, 6 insertions(+), 6 deletions(-)
rename test.html => test/index.html (86%)
rename sandbox.html => test/sandbox.html (100%)
rename server.js => test/server.js (90%)
rename test.js => test/tests.js (100%)
diff --git a/README.md b/README.md
index 91e8592..0f639ac 100644
--- a/README.md
+++ b/README.md
@@ -98,11 +98,11 @@ If true, the cookie transmission requires a secure protocol (https). Default: `f
Requires Node. Startup server:
- $ node server.js
+ $ node test/server.js
Open in browser:
- $ open http://0.0.0.0:8124/test.html
+ $ open http://0.0.0.0:8124/test/index.html
For quick *non cross-browser* testing use grunt:
diff --git a/grunt.js b/grunt.js
index fa9aff0..e50f08f 100644
--- a/grunt.js
+++ b/grunt.js
@@ -4,7 +4,7 @@ module.exports = function (grunt) {
grunt.initConfig({
qunit: {
- files: ['test.html']
+ files: ['test/index.html']
},
lint: {
files: [
diff --git a/test.html b/test/index.html
similarity index 86%
rename from test.html
rename to test/index.html
index bf5a08f..1a6016b 100644
--- a/test.html
+++ b/test/index.html
@@ -6,8 +6,8 @@
-
-
+
+
diff --git a/sandbox.html b/test/sandbox.html
similarity index 100%
rename from sandbox.html
rename to test/sandbox.html
diff --git a/server.js b/test/server.js
similarity index 90%
rename from server.js
rename to test/server.js
index 8136795..8d2e712 100644
--- a/server.js
+++ b/test/server.js
@@ -21,4 +21,4 @@ http.createServer(function(request, response) {
});
}).listen(8124, '0.0.0.0');
-console.log('Test suite at http://0.0.0.0:8124/test.html');
+console.log('Test suite at http://0.0.0.0:8124/test/index.html');
diff --git a/test.js b/test/tests.js
similarity index 100%
rename from test.js
rename to test/tests.js
From 014706b2665c665df3a692ddc8e9cae5c20be830 Mon Sep 17 00:00:00 2001
From: Klaus Hartl
Date: Fri, 25 Jan 2013 22:18:30 +0100
Subject: [PATCH 03/96] Fixing path to jquery.cookie.js
---
test/sandbox.html | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/test/sandbox.html b/test/sandbox.html
index 1f65de7..b4a3f78 100644
--- a/test/sandbox.html
+++ b/test/sandbox.html
@@ -3,7 +3,7 @@
-
+
+```html
+
+```
**Do not include the script directly from GitHub (http://raw.github.com/...).** The file is being served as text/plain and as such being blocked
in Internet Explorer on Windows 7 for instance (because of the wrong MIME type). Bottom line: GitHub is not a CDN.
@@ -19,32 +21,44 @@ The plugin can also be loaded as AMD module.
Create session cookie:
- $.cookie('the_cookie', 'the_value');
+```javascript
+$.cookie('the_cookie', 'the_value');
+```
Create expiring cookie, 7 days from then:
- $.cookie('the_cookie', 'the_value', { expires: 7 });
+```javascript
+$.cookie('the_cookie', 'the_value', { expires: 7 });
+```
Create expiring cookie, valid across entire site:
- $.cookie('the_cookie', 'the_value', { expires: 7, path: '/' });
+```javascript
+$.cookie('the_cookie', 'the_value', { expires: 7, path: '/' });
+```
Read cookie:
- $.cookie('the_cookie'); // => "the_value"
- $.cookie('not_existing'); // => undefined
+```javascript
+$.cookie('the_cookie'); // => "the_value"
+$.cookie('not_existing'); // => undefined
+```
Read all available cookies:
- $.cookie(); // => { "the_cookie": "the_value", "...remaining": "cookies" }
+```javascript
+$.cookie(); // => { "the_cookie": "the_value", "...remaining": "cookies" }
+```
Delete cookie:
- // Returns true when cookie was found, false when no cookie was found...
- $.removeCookie('the_cookie');
+```javascript
+// Returns true when cookie was found, false when no cookie was found...
+$.removeCookie('the_cookie');
- // Same path as when the cookie was written...
- $.removeCookie('the_cookie', { path: '/' });
+// Same path as when the cookie was written...
+$.removeCookie('the_cookie', { path: '/' });
+```
*Note: when deleting a cookie, you must pass the exact same path, domain and secure options that were used to set the cookie, unless you're relying on the default options that is.*
@@ -54,13 +68,17 @@ Delete cookie:
By default the cookie value is encoded/decoded when writing/reading, using `encodeURIComponent`/`decodeURIComponent`. Bypass this by setting raw to true:
- $.cookie.raw = true;
+```javascript
+$.cookie.raw = true;
+```
### json
Turn on automatic storage of JSON objects passed as the cookie value. Assumes `JSON.stringify` and `JSON.parse`:
- $.cookie.json = true;
+```javascript
+$.cookie.json = true;
+```
## Cookie Options
From 3caf209abe30a856789d0ceb464c297dfdbe670e Mon Sep 17 00:00:00 2001
From: Klaus Hartl
Date: Sat, 5 Oct 2013 20:24:16 +0200
Subject: [PATCH 43/96] Preparing for 1.4.0 release
---
CHANGELOG.md | 3 +++
README.md | 2 +-
bower.json | 2 +-
cookie.jquery.json | 2 +-
jquery.cookie.js | 2 +-
package.json | 2 +-
6 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 246232d..467dd42 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,8 @@
HEAD
-----
+
+1.4.0
+-----
- Support for AMD.
- Removed deprecated method `$.cookie('name', null)` for deleting a cookie,
diff --git a/README.md b/README.md
index a5ad9f3..7377611 100644
--- a/README.md
+++ b/README.md
@@ -118,7 +118,7 @@ If true, the cookie transmission requires a secure protocol (https). Default: `f
## Converters
-Provide a conversion function as optional last argument for reading, in order to change the cookie's value
+Provide a conversion function as optional last argument for reading, in order to change the cookie's value
to a different representation on the fly.
Example for parsing a value into a number:
diff --git a/bower.json b/bower.json
index dd91171..8a5b5d0 100644
--- a/bower.json
+++ b/bower.json
@@ -1,6 +1,6 @@
{
"name": "jquery.cookie",
- "version": "1.3.1",
+ "version": "1.4.0",
"main": [
"./jquery.cookie.js"
],
diff --git a/cookie.jquery.json b/cookie.jquery.json
index 9267e69..522d5e1 100644
--- a/cookie.jquery.json
+++ b/cookie.jquery.json
@@ -1,6 +1,6 @@
{
"name": "cookie",
- "version": "1.3.1",
+ "version": "1.4.0",
"title": "jQuery Cookie",
"description": "A simple, lightweight jQuery plugin for reading, writing and deleting cookies.",
"author": {
diff --git a/jquery.cookie.js b/jquery.cookie.js
index d1b32c1..9271900 100644
--- a/jquery.cookie.js
+++ b/jquery.cookie.js
@@ -1,5 +1,5 @@
/*!
- * jQuery Cookie Plugin v1.3.1
+ * jQuery Cookie Plugin v1.4.0
* https://github.com/carhartl/jquery-cookie
*
* Copyright 2013 Klaus Hartl
diff --git a/package.json b/package.json
index 761f17a..3942d32 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "jquery.cookie",
- "version": "1.3.1",
+ "version": "1.4.0",
"description": "A simple, lightweight jQuery plugin for reading, writing and deleting cookies.",
"main": "Gruntfile.js",
"directories": {
From 0ae9f7eec0f56c677c826094eb126060a50b93b6 Mon Sep 17 00:00:00 2001
From: Klaus Hartl
Date: Wed, 16 Oct 2013 12:17:58 +0200
Subject: [PATCH 44/96] Fix return value for $.removeCookie() in case cookie
deletion failed for whatever reason.
Closes #224.
---
jquery.cookie.js | 11 +++++-----
test/tests.js | 54 ++++++++++++++++++++++++++++--------------------
2 files changed, 38 insertions(+), 27 deletions(-)
diff --git a/jquery.cookie.js b/jquery.cookie.js
index 9271900..72d3cd2 100644
--- a/jquery.cookie.js
+++ b/jquery.cookie.js
@@ -106,12 +106,13 @@
config.defaults = {};
$.removeCookie = function (key, options) {
- if ($.cookie(key) !== undefined) {
- // Must not alter options, thus extending a fresh object...
- $.cookie(key, '', $.extend({}, options, { expires: -1 }));
- return true;
+ if ($.cookie(key) === undefined) {
+ return false;
}
- return false;
+
+ // Must not alter options, thus extending a fresh object...
+ $.cookie(key, '', $.extend({}, options, { expires: -1 }));
+ return !$.cookie(key);
};
}));
diff --git a/test/tests.js b/test/tests.js
index c5c3171..8f75b42 100644
--- a/test/tests.js
+++ b/test/tests.js
@@ -110,7 +110,9 @@ test('invalid URL encoding', function () {
expect(1);
document.cookie = 'bad=foo%';
strictEqual($.cookie('bad'), undefined, "won't throw exception, returns undefined");
- document.cookie = 'bad=foo'; // Allow to be deleted...
+ // Delete manually here because it requires raw === true...
+ $.cookie.raw = true;
+ $.removeCookie('bad');
});
asyncTest('malformed cookie value in IE (#88, #117)', function () {
@@ -152,6 +154,9 @@ test('Call to read all with a badly encoded cookie', function () {
document.cookie = 'bad=foo%';
document.cookie = 'good=foo';
deepEqual($.cookie(), { good: 'foo' }, 'returns object containing all decodable cookies');
+ // Delete manually here because it requires raw === true...
+ $.cookie.raw = true;
+ $.removeCookie('bad');
});
@@ -213,7 +218,8 @@ test('raw = true', function () {
expect(1);
$.cookie.raw = true;
strictEqual($.cookie('c[1]', 'v[1]'), 'c[1]=v[1]', 'should not encode');
- $.each($.cookie(), $.removeCookie);
+ // Delete manually here because it requires raw === true...
+ $.removeCookie('c[1]');
});
test('json = true', function () {
@@ -238,42 +244,46 @@ test('deletion', function () {
strictEqual(document.cookie, '', 'should delete the cookie');
});
-test('return', function () {
- expect(2);
- strictEqual($.removeCookie('c'), false, "return false if the cookie wasn't found");
-
+test('when sucessfully deleted', function () {
+ expect(1);
$.cookie('c', 'v');
- strictEqual($.removeCookie('c'), true, 'return true if the cookie was found');
+ strictEqual($.removeCookie('c'), true, 'returns true');
});
-test('with options', function () {
- expect(3);
- var originalCookie = $.cookie;
- var callCount = 0;
+test('when deletion failed', function () {
+ expect(1);
+ $.cookie('c', 'v');
+ var originalCookie = $.cookie;
$.cookie = function () {
- callCount++;
- if (callCount === 1) {
- // see https://github.com/carhartl/jquery-cookie/issues/99
- strictEqual(arguments.length, 1, 'look up cookie instead of accidently writing a new');
- return 'cookie'; // act as if a cookie was found...
- }
- if (callCount === 2) {
- strictEqual(arguments[2].foo, 'bar', 'pass along options when deleting cookie');
+ // Stub deletion...
+ if (arguments.length === 1) {
+ return originalCookie.apply(null, arguments);
}
};
- $.removeCookie('c', { foo: 'bar' });
- strictEqual(callCount, 2);
+ strictEqual($.removeCookie('c'), false, 'returns false');
$.cookie = originalCookie;
});
-test('passing options reference', function () {
+test('when cookie does not exist', function () {
+ expect(1);
+ strictEqual($.removeCookie('c'), false, 'returns false');
+});
+
+test('with options', function () {
expect(1);
var options = { path: '/' };
$.cookie('c', 'v', options);
+ $.removeCookie('c', options);
+ strictEqual(document.cookie, '', 'should delete the cookie');
+});
+test('passing options reference', function () {
+ expect(1);
+ var options = { path: '/' };
+ $.cookie('c', 'v', options);
$.removeCookie('c', options);
deepEqual(options, { path: '/' }, "won't alter options object");
});
From 3ab35ab43ef4aed1c3d463ce8e0a86c914b0d260 Mon Sep 17 00:00:00 2001
From: Klaus Hartl
Date: Thu, 24 Oct 2013 23:13:32 +0200
Subject: [PATCH 45/96] Using a single try/catch block instead of two.
---
jquery.cookie.js | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/jquery.cookie.js b/jquery.cookie.js
index 72d3cd2..6aee051 100644
--- a/jquery.cookie.js
+++ b/jquery.cookie.js
@@ -38,13 +38,8 @@
try {
// Replace server-side written pluses with spaces.
// If we can't decode the cookie, ignore it, it's unusable.
- s = decodeURIComponent(s.replace(pluses, ' '));
- } catch(e) {
- return;
- }
-
- try {
// If we can't parse the cookie, ignore it, it's unusable.
+ s = decodeURIComponent(s.replace(pluses, ' '));
return config.json ? JSON.parse(s) : s;
} catch(e) {}
}
From 7984c941e06b071eaf3eac9cfbd171decd3b75b2 Mon Sep 17 00:00:00 2001
From: Klaus Hartl
Date: Wed, 30 Oct 2013 16:20:01 +0100
Subject: [PATCH 46/96] Adding Code Climate badge.
Closes #228.
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 7377611..dfa1586 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-# jquery.cookie [](https://travis-ci.org/carhartl/jquery-cookie)
+# jquery.cookie [](https://travis-ci.org/carhartl/jquery-cookie) [](https://codeclimate.com/github/carhartl/jquery-cookie)
[](https://saucelabs.com/u/carhartl)
From 8947f435c39b209d1ef4c46284702c2e0d03678b Mon Sep 17 00:00:00 2001
From: Klaus Hartl
Date: Wed, 30 Oct 2013 16:41:28 +0100
Subject: [PATCH 47/96] Using correctly set up Sauce Labs account (one for open
source). Should fix badge not showing up.
---
.travis.yml | 4 ++--
README.md | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index 3b84117..b65fdbd 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -6,5 +6,5 @@ before_script:
script: grunt ci --verbose
env:
global:
- - secure: FjCPTpIs6l6zTvXqH9rPTXqeRCpNa0cmz2Glio8fmOhbdeNbAdQTZGPChe8wTqIQ4wRQUtg4BPZjYx4+ibhj530/QW+736d9UUX5MhixCbm9r6EzRuljlo0wGRsLRa3pHIKyxq18bdilBSYaPrbekpLSyCKM/3wJa34k8LNKdrg=
- - secure: dJU6/DdQkuhVNSuaR1OswON7cHjRR7mDv0szIZ1rY/TRNoL6GrDr7XGpeQAtV+6Pqu1RJWb1V0VHoPble6imYqWtiq9LZu8UtU/ImKkZWZxFgMyDDJEli4Lw/+p1UMBNf7jXM3v8t9aOA0eHTwX7IA++paNIdehBOyNI8x3t6Ng=
+ - secure: HRae0kyIDDuhonvMi2SfEl1WJb4K/wX8WmzT9YkxFbmWwLjiOMkmqyuEyi76DbTC1cb9o7WwGVgbP1DhSm6n6m0Lz+PSzpprBN4QZuJc56jcc+tBA6gM81hyUufaTT0yUWz112Bu06kWIAs44w5PtG0FYZR0CuIN8fQvZi8fXCQ=
+ - secure: c+M5ECIfxDcVrr+ZlqgpGjv8kVM/hxiz3ACMCn4ZkDiaeq4Rw0wWIGZYL6aV5fhsoHgzEQ/XQPca8xKs3Umr7R3b6Vr3AEyFnW+LP67K/1Qbz4Pi3PvhDH/h4rvK7fOoTqTDCVVDEH3v4pefsz2VaKemG4iBKxrcof5aR4Rjopk=
diff --git a/README.md b/README.md
index dfa1586..1c1f068 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
# jquery.cookie [](https://travis-ci.org/carhartl/jquery-cookie) [](https://codeclimate.com/github/carhartl/jquery-cookie)
-[](https://saucelabs.com/u/carhartl)
+[](https://saucelabs.com/u/jquery-cookie)
A simple, lightweight jQuery plugin for reading, writing and deleting cookies.
From ac265dcb3bd0d18252396a0ce6db5c4a4c420069 Mon Sep 17 00:00:00 2001
From: Klaus Hartl
Date: Thu, 31 Oct 2013 09:09:15 +0100
Subject: [PATCH 48/96] Moving build status matrix below description. [ci skip]
---
README.md | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/README.md b/README.md
index 1c1f068..e409147 100644
--- a/README.md
+++ b/README.md
@@ -1,9 +1,11 @@
# jquery.cookie [](https://travis-ci.org/carhartl/jquery-cookie) [](https://codeclimate.com/github/carhartl/jquery-cookie)
-[](https://saucelabs.com/u/jquery-cookie)
-
A simple, lightweight jQuery plugin for reading, writing and deleting cookies.
+## Build Status Matrix
+
+[](https://saucelabs.com/u/jquery-cookie)
+
## Installation
Include script *after* the jQuery library (unless you are packaging scripts somehow else):
From 580416a8b08e33d819a92fca7f4caa8d9ca6527c Mon Sep 17 00:00:00 2001
From: Guy Bedford
Date: Tue, 26 Nov 2013 16:51:36 +0200
Subject: [PATCH 49/96] add jspm package.json config
---
package.json | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/package.json b/package.json
index 3942d32..2553b83 100644
--- a/package.json
+++ b/package.json
@@ -27,5 +27,12 @@
"grunt-saucelabs": "~4.1.1",
"grunt-contrib-connect": "~0.5.0",
"gzip-js": "~0.3.0"
+ },
+ "jspm": {
+ "main": "jquery.cookie",
+ "files": ["jquery.cookie.js"],
+ "buildConfig": {
+ "uglify": true
+ }
}
}
From ecb597b65e4c477baa2b30a2a5a67fdaee9870ea Mon Sep 17 00:00:00 2001
From: Klaus Hartl
Date: Fri, 29 Nov 2013 22:54:53 +0100
Subject: [PATCH 50/96] Allow fractions of a day for expires option.
Closes #246.
---
jquery.cookie.js | 3 ++-
test/tests.js | 12 ++++++++++++
2 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/jquery.cookie.js b/jquery.cookie.js
index 6aee051..6412847 100644
--- a/jquery.cookie.js
+++ b/jquery.cookie.js
@@ -52,12 +52,13 @@
var config = $.cookie = function (key, value, options) {
// Write
+
if (value !== undefined && !$.isFunction(value)) {
options = $.extend({}, config.defaults, options);
if (typeof options.expires === 'number') {
var days = options.expires, t = options.expires = new Date();
- t.setDate(t.getDate() + days);
+ t.setTime(+t + days * 864e+5);
}
return (document.cookie = [
diff --git a/test/tests.js b/test/tests.js
index 8f75b42..f1c357a 100644
--- a/test/tests.js
+++ b/test/tests.js
@@ -194,6 +194,18 @@ test('expires option as days from now', function () {
'should write the cookie string with expires');
});
+test('expires option as fraction of a day', function () {
+ expect(1);
+
+ now = new Date().getTime();
+ expires = Date.parse($.cookie('c', 'v', { expires: 0.5 }));
+
+ // When we were using Date.setDate() fractions have been ignored
+ // and expires resulted in the current date. Allow 1000 milliseconds
+ // difference for execution time.
+ ok(expires > now + 1000, 'should write expires attribute with the correct date');
+});
+
test('expires option as Date instance', function () {
expect(1);
var sevenDaysFromNow = new Date();
From fbb0117ff06f7d7410c4243af8906e64d3ad27de Mon Sep 17 00:00:00 2001
From: Klaus Hartl
Date: Sat, 30 Nov 2013 14:06:17 +0100
Subject: [PATCH 51/96] Date.parse works a bit different in Firefox and IE and
Webkit. Also fixing the creation of global variables in the test.
---
test/tests.js | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/test/tests.js b/test/tests.js
index f1c357a..bd32552 100644
--- a/test/tests.js
+++ b/test/tests.js
@@ -197,8 +197,8 @@ test('expires option as days from now', function () {
test('expires option as fraction of a day', function () {
expect(1);
- now = new Date().getTime();
- expires = Date.parse($.cookie('c', 'v', { expires: 0.5 }));
+ var now = new Date().getTime();
+ var expires = Date.parse($.cookie('c', 'v', { expires: 0.5 }).replace(/.+expires=/, ''));
// When we were using Date.setDate() fractions have been ignored
// and expires resulted in the current date. Allow 1000 milliseconds
From d24eb23c3f045fe96e9e2993529a91478a97fca8 Mon Sep 17 00:00:00 2001
From: "Bruno Winck, Kneaver"
Date: Fri, 27 Dec 2013 15:21:37 +0530
Subject: [PATCH 52/96] Add component.json to support component.io
---
component.json | 14 ++++++++++++++
1 file changed, 14 insertions(+)
create mode 100644 component.json
diff --git a/component.json b/component.json
new file mode 100644
index 0000000..5e6ae45
--- /dev/null
+++ b/component.json
@@ -0,0 +1,14 @@
+{
+ "name": "jquery.cookie",
+ "repo": "carhartl/jquery-cookie",
+ "description": "A simple, lightweight jQuery plugin for reading, writing and deleting cookies",
+ "version": "1.4.0",
+ "keywords": [],
+ "dependencies": {},
+ "development": {},
+ "license": "MIT",
+ "main": "jquery.cookie.js",
+ "scripts": [
+ "jquery.cookie.js"
+ ]
+}
\ No newline at end of file
From 3646a0de3e271641a3e232d39e29e71bdab16850 Mon Sep 17 00:00:00 2001
From: Colin Rymer
Date: Tue, 28 Jan 2014 11:02:28 -0500
Subject: [PATCH 53/96] add jamjs support
---
package.json | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/package.json b/package.json
index 2553b83..721ca67 100644
--- a/package.json
+++ b/package.json
@@ -34,5 +34,14 @@
"buildConfig": {
"uglify": true
}
+ },
+ "jam": {
+ "dependencies": {
+ "jquery": ">=1.2"
+ },
+ "main": "jquery.cookie.js",
+ "include": [
+ "jquery.cookie.js"
+ ]
}
}
From 433a10696e71f1584662cae507c404f4bfbb9526 Mon Sep 17 00:00:00 2001
From: Klaus Hartl
Date: Tue, 28 Jan 2014 21:03:09 +0100
Subject: [PATCH 54/96] Adding note about the documentation in master vs latest
release
---
README.md | 3 +++
1 file changed, 3 insertions(+)
diff --git a/README.md b/README.md
index e409147..6def3e1 100644
--- a/README.md
+++ b/README.md
@@ -2,6 +2,9 @@
A simple, lightweight jQuery plugin for reading, writing and deleting cookies.
+**If you're viewing this at https://github.com/carhartl/jquery-cookie, you're reading the documentation for the master branch.
+[View documentation for the latest release (1.4.0).](https://github.com/carhartl/jquery-cookie/tree/v1.4.0)**
+
## Build Status Matrix
[](https://saucelabs.com/u/jquery-cookie)
From 92c3fd0ad5cfa45ff03914969912fad4c4a9861a Mon Sep 17 00:00:00 2001
From: Wil Moore III
Date: Mon, 10 Feb 2014 15:48:51 -0700
Subject: [PATCH 55/96] Fix package.json main property
This allows tools like volo to know which file to include in a dependent's lib directory.
---
package.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/package.json b/package.json
index 2553b83..07395f5 100644
--- a/package.json
+++ b/package.json
@@ -2,7 +2,7 @@
"name": "jquery.cookie",
"version": "1.4.0",
"description": "A simple, lightweight jQuery plugin for reading, writing and deleting cookies.",
- "main": "Gruntfile.js",
+ "main": "jquery.cookie.js",
"directories": {
"test": "test"
},
From 5421819450666bada6d1aed655cfaf4e85a4f88b Mon Sep 17 00:00:00 2001
From: Wil Moore III
Date: Mon, 10 Feb 2014 15:51:36 -0700
Subject: [PATCH 56/96] Download hint for volo
---
package.json | 3 +++
1 file changed, 3 insertions(+)
diff --git a/package.json b/package.json
index 2553b83..9324fee 100644
--- a/package.json
+++ b/package.json
@@ -28,6 +28,9 @@
"grunt-contrib-connect": "~0.5.0",
"gzip-js": "~0.3.0"
},
+ "volo": {
+ "url": "https://raw.github.com/carhartl/jquery-cookie/v{version}/jquery.cookie.js"
+ },
"jspm": {
"main": "jquery.cookie",
"files": ["jquery.cookie.js"],
From 6e175cd71e0d4cf8b64739b3128ddef5a33c938a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gasto=CC=81n=20Omar=20Sa=CC=81nchez=20Rui=CC=81z?=
Date: Tue, 11 Feb 2014 21:36:39 -0600
Subject: [PATCH 57/96] Add CommonJS support
---
.jshintrc | 3 ++-
README.md | 2 +-
jquery.cookie.js | 3 +++
3 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/.jshintrc b/.jshintrc
index b0af059..a37f48c 100644
--- a/.jshintrc
+++ b/.jshintrc
@@ -11,6 +11,7 @@
"undef": true,
"globals": {
"define": true,
- "jQuery": true
+ "jQuery": true,
+ "require": true
}
}
diff --git a/README.md b/README.md
index 6def3e1..536b5a0 100644
--- a/README.md
+++ b/README.md
@@ -20,7 +20,7 @@ Include script *after* the jQuery library (unless you are packaging scripts some
**Do not include the script directly from GitHub (http://raw.github.com/...).** The file is being served as text/plain and as such being blocked
in Internet Explorer on Windows 7 for instance (because of the wrong MIME type). Bottom line: GitHub is not a CDN.
-The plugin can also be loaded as AMD module.
+The plugin can also be loaded as AMD or CommonJS module.
## Usage
diff --git a/jquery.cookie.js b/jquery.cookie.js
index 6412847..2f84144 100644
--- a/jquery.cookie.js
+++ b/jquery.cookie.js
@@ -9,6 +9,9 @@
if (typeof define === 'function' && define.amd) {
// AMD. Register as anonymous module.
define(['jquery'], factory);
+ } else if (typeof exports === 'object') {
+ // CommonJS
+ factory(require('jquery'));
} else {
// Browser globals.
factory(jQuery);
From 187c874c6727f4c9518e6565e1b742192de80bb5 Mon Sep 17 00:00:00 2001
From: Klaus Hartl
Date: Fri, 28 Feb 2014 20:08:17 +0100
Subject: [PATCH 58/96] Write comments in a consistent manner
---
jquery.cookie.js | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/jquery.cookie.js b/jquery.cookie.js
index 2f84144..211da5c 100644
--- a/jquery.cookie.js
+++ b/jquery.cookie.js
@@ -7,13 +7,13 @@
*/
(function (factory) {
if (typeof define === 'function' && define.amd) {
- // AMD. Register as anonymous module.
+ // AMD
define(['jquery'], factory);
} else if (typeof exports === 'object') {
// CommonJS
factory(require('jquery'));
} else {
- // Browser globals.
+ // Browser globals
factory(jQuery);
}
}(function ($) {
From 5b12a4e11dd167d6227cb866ee6e88134cdae813 Mon Sep 17 00:00:00 2001
From: Klaus Hartl
Date: Fri, 28 Feb 2014 20:34:35 +0100
Subject: [PATCH 59/96] Adding missing newline at the end
---
component.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/component.json b/component.json
index 5e6ae45..6b7122a 100644
--- a/component.json
+++ b/component.json
@@ -11,4 +11,4 @@
"scripts": [
"jquery.cookie.js"
]
-}
\ No newline at end of file
+}
From 8f641ded8a1f6b7697161e258592c9d388d15485 Mon Sep 17 00:00:00 2001
From: Klaus Hartl
Date: Tue, 4 Mar 2014 09:55:57 +0100
Subject: [PATCH 60/96] Updating changelog, preparing for next release
---
CHANGELOG.md | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 467dd42..80511c2 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,12 @@
HEAD
-----
+- Added support for CommonJS.
+
+- Added support for package managers: Jam (http://jamjs.org), volo (http://volojs.org), Component (http://component.io), jspm (http://jspm.io).
+
+- The expires option now interpretes fractions of numbers (e.g. days) correctly.
+
1.4.0
-----
- Support for AMD.
From 9481ec9eb649e10cd8650d58c0170a36b2da10e7 Mon Sep 17 00:00:00 2001
From: Klaus Hartl
Date: Tue, 4 Mar 2014 09:58:05 +0100
Subject: [PATCH 61/96] Removing newline
---
CHANGELOG.md | 1 -
1 file changed, 1 deletion(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 80511c2..e72e6d2 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,5 @@
HEAD
-----
-
- Added support for CommonJS.
- Added support for package managers: Jam (http://jamjs.org), volo (http://volojs.org), Component (http://component.io), jspm (http://jspm.io).
From 38b998b9780e52da3952ab57572c36f46280a79a Mon Sep 17 00:00:00 2001
From: Nicholas Van de walle
Date: Fri, 14 Mar 2014 09:00:09 -0700
Subject: [PATCH 62/96] Update MIT-LICENSE.txt
Updated your license to the current year.
---
MIT-LICENSE.txt | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/MIT-LICENSE.txt b/MIT-LICENSE.txt
index 8ae647b..7a631e8 100644
--- a/MIT-LICENSE.txt
+++ b/MIT-LICENSE.txt
@@ -1,4 +1,4 @@
-Copyright 2013 Klaus Hartl
+Copyright 2014 Klaus Hartl
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
@@ -17,4 +17,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\ No newline at end of file
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
From 7f88a4e631aba8a8c688fd8999ce6b9bcfd50718 Mon Sep 17 00:00:00 2001
From: Klaus Hartl
Date: Sun, 27 Apr 2014 22:07:15 +0200
Subject: [PATCH 63/96] Preparing for 1.4.1 release
---
CHANGELOG.md | 3 +++
README.md | 2 +-
bower.json | 2 +-
component.json | 2 +-
cookie.jquery.json | 2 +-
jquery.cookie.js | 2 +-
package.json | 2 +-
7 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index e72e6d2..59d868f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,8 @@
HEAD
-----
+
+1.4.1
+-----
- Added support for CommonJS.
- Added support for package managers: Jam (http://jamjs.org), volo (http://volojs.org), Component (http://component.io), jspm (http://jspm.io).
diff --git a/README.md b/README.md
index 536b5a0..f9a7494 100644
--- a/README.md
+++ b/README.md
@@ -3,7 +3,7 @@
A simple, lightweight jQuery plugin for reading, writing and deleting cookies.
**If you're viewing this at https://github.com/carhartl/jquery-cookie, you're reading the documentation for the master branch.
-[View documentation for the latest release (1.4.0).](https://github.com/carhartl/jquery-cookie/tree/v1.4.0)**
+[View documentation for the latest release (1.4.1).](https://github.com/carhartl/jquery-cookie/tree/v1.4.1)**
## Build Status Matrix
diff --git a/bower.json b/bower.json
index 8a5b5d0..2d8c25b 100644
--- a/bower.json
+++ b/bower.json
@@ -1,6 +1,6 @@
{
"name": "jquery.cookie",
- "version": "1.4.0",
+ "version": "1.4.1",
"main": [
"./jquery.cookie.js"
],
diff --git a/component.json b/component.json
index 6b7122a..58f79d6 100644
--- a/component.json
+++ b/component.json
@@ -2,7 +2,7 @@
"name": "jquery.cookie",
"repo": "carhartl/jquery-cookie",
"description": "A simple, lightweight jQuery plugin for reading, writing and deleting cookies",
- "version": "1.4.0",
+ "version": "1.4.1",
"keywords": [],
"dependencies": {},
"development": {},
diff --git a/cookie.jquery.json b/cookie.jquery.json
index 522d5e1..69d5748 100644
--- a/cookie.jquery.json
+++ b/cookie.jquery.json
@@ -1,6 +1,6 @@
{
"name": "cookie",
- "version": "1.4.0",
+ "version": "1.4.1",
"title": "jQuery Cookie",
"description": "A simple, lightweight jQuery plugin for reading, writing and deleting cookies.",
"author": {
diff --git a/jquery.cookie.js b/jquery.cookie.js
index 211da5c..c7f3a59 100644
--- a/jquery.cookie.js
+++ b/jquery.cookie.js
@@ -1,5 +1,5 @@
/*!
- * jQuery Cookie Plugin v1.4.0
+ * jQuery Cookie Plugin v1.4.1
* https://github.com/carhartl/jquery-cookie
*
* Copyright 2013 Klaus Hartl
diff --git a/package.json b/package.json
index e5493d1..d52070a 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "jquery.cookie",
- "version": "1.4.0",
+ "version": "1.4.1",
"description": "A simple, lightweight jQuery plugin for reading, writing and deleting cookies.",
"main": "jquery.cookie.js",
"directories": {
From 120dc4cd1bbac59a1b6ce4e80a158b54cda68b81 Mon Sep 17 00:00:00 2001
From: Klaus Hartl
Date: Mon, 28 Apr 2014 21:59:21 +0200
Subject: [PATCH 64/96] Updating Sauce Labs browsers to test in CI, closes #288
---
Gruntfile.js | 65 ++++++++++++++++++++++++++++++++++++++++++++--------
1 file changed, 55 insertions(+), 10 deletions(-)
diff --git a/Gruntfile.js b/Gruntfile.js
index 9c30c00..acd3c77 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -65,35 +65,80 @@ module.exports = function (grunt) {
build: process.env.TRAVIS_JOB_ID,
concurrency: 3,
browsers: [
+ // iOS
{
- browserName: 'safari',
- platform: 'OS X 10.8'
+ browserName: 'iphone',
+ platform: 'OS X 10.9',
+ version: '7.1'
},
{
- browserName: 'firefox',
- platform: 'Windows 7'
+ browserName: 'ipad',
+ platform: 'OS X 10.9',
+ version: '7.1'
},
+ // Android
{
- browserName: 'firefox',
- platform: 'Windows XP'
+ browserName: 'android',
+ platform: 'Linux',
+ version: '4.3'
},
+ // OS X
{
- browserName: 'firefox',
- platform: 'Linux'
+ browserName: 'safari',
+ platform: 'OS X 10.9',
+ version: '7'
},
{
- browserName: 'chrome',
- platform: 'Windows 7'
+ browserName: 'safari',
+ platform: 'OS X 10.8',
+ version: '6'
+ },
+ // Windows
+ {
+ browserName: 'internet explorer',
+ platform: 'Windows 8.1',
+ version: '11'
},
{
browserName: 'internet explorer',
platform: 'Windows 8',
version: '10'
},
+ {
+ browserName: 'internet explorer',
+ platform: 'Windows 7',
+ version: '11'
+ },
+ {
+ browserName: 'internet explorer',
+ platform: 'Windows 7',
+ version: '10'
+ },
{
browserName: 'internet explorer',
platform: 'Windows 7',
version: '9'
+ },
+ {
+ browserName: 'internet explorer',
+ platform: 'Windows 7',
+ version: '8'
+ },
+ {
+ browserName: 'firefox',
+ platform: 'Windows 7',
+ version: '28'
+ },
+ {
+ browserName: 'chrome',
+ platform: 'Windows 7',
+ version: '34'
+ },
+ // Linux
+ {
+ browserName: 'firefox',
+ platform: 'Linux',
+ version: '28'
}
],
testname: 'jquery.cookie qunit tests'
From 288af0659a8371fa1128133f1205eac3afb4633a Mon Sep 17 00:00:00 2001
From: Klaus Hartl
Date: Tue, 6 May 2014 09:54:31 +0200
Subject: [PATCH 65/96] Updating to use latest Firefox for Sauce Labs CI
---
Gruntfile.js | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/Gruntfile.js b/Gruntfile.js
index acd3c77..cb0df23 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -93,6 +93,11 @@ module.exports = function (grunt) {
platform: 'OS X 10.8',
version: '6'
},
+ {
+ browserName: 'firefox',
+ platform: 'OS X 10.9',
+ version: '28'
+ },
// Windows
{
browserName: 'internet explorer',
@@ -127,7 +132,7 @@ module.exports = function (grunt) {
{
browserName: 'firefox',
platform: 'Windows 7',
- version: '28'
+ version: '29'
},
{
browserName: 'chrome',
@@ -138,7 +143,7 @@ module.exports = function (grunt) {
{
browserName: 'firefox',
platform: 'Linux',
- version: '28'
+ version: '29'
}
],
testname: 'jquery.cookie qunit tests'
From e2a881c9694a39b57cb7eff8a4f64ebd6a144456 Mon Sep 17 00:00:00 2001
From: Klaus Hartl
Date: Tue, 6 May 2014 10:03:30 +0200
Subject: [PATCH 66/96] Update jQuery used in the tests
---
test/index.html | 2 +-
test/malformed_cookie.html | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/test/index.html b/test/index.html
index 1a6016b..2c0aec1 100644
--- a/test/index.html
+++ b/test/index.html
@@ -4,7 +4,7 @@
jquery.cookie Test Suite
-
+
diff --git a/test/malformed_cookie.html b/test/malformed_cookie.html
index b4a3f78..3aab83f 100644
--- a/test/malformed_cookie.html
+++ b/test/malformed_cookie.html
@@ -2,7 +2,7 @@
-
+
-
+
From e9fe5559e4b69aedf6a916a3e27e2a8cfda6f079 Mon Sep 17 00:00:00 2001
From: Klaus Hartl
Date: Fri, 9 May 2014 21:51:57 +0200
Subject: [PATCH 68/96] Use `grunt connect:server:keepalive` to start a server,
removing the one in test.
Closes #287.
---
CONTRIBUTING.md | 6 +++---
test/server.js | 24 ------------------------
2 files changed, 3 insertions(+), 27 deletions(-)
delete mode 100644 test/server.js
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index f174678..50ef6d5 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -14,7 +14,7 @@
We use the following tools for development:
- [Qunit](http://qunitjs.com/) for tests.
-- [NodeJS](http://nodejs.org/download/) required to run grunt and the test server only.
+- [NodeJS](http://nodejs.org/download/) required to run grunt.
- [Grunt](http://gruntjs.com/getting-started) for task management.
###Getting started
@@ -39,11 +39,11 @@ You should see a green message in the console:
You can also run the tests in the browser.
Start a test server from the project root:
- $ node test/server.js
+ $ grunt connect:server:keepalive
Open the following URL in a browser:
- $ open http://0.0.0.0:8124/test/index.html
+ $ open http://127.0.0.1:9999/test/index.html
_Note: we recommend cleaning all the browser cookies before running the tests, that can avoid false positive failures._
diff --git a/test/server.js b/test/server.js
deleted file mode 100644
index 8d2e712..0000000
--- a/test/server.js
+++ /dev/null
@@ -1,24 +0,0 @@
-var http = require('http');
-var url = require('url');
-var path = require('path');
-var fs = require('fs');
-
-http.createServer(function(request, response) {
- var uri = url.parse(request.url).pathname;
- var filename = path.join(process.cwd(), uri);
-
- fs.readFile(filename, 'binary', function(err, file) {
- if (err) {
- response.writeHead(500, { 'Content-Type': 'text/plain' });
- response.write(err + '\n');
- response.end();
- return;
- }
-
- response.writeHead(200, filename.match(/\.js$/) ? { 'Content-Type': 'text/javascript' } : {});
- response.write(file, 'utf-8');
- response.end();
- });
-}).listen(8124, '0.0.0.0');
-
-console.log('Test suite at http://0.0.0.0:8124/test/index.html');
From c5ad0163f0259553b6933f3ef72f80c80db5fa9c Mon Sep 17 00:00:00 2001
From: Klaus Hartl
Date: Fri, 9 May 2014 22:07:54 +0200
Subject: [PATCH 69/96] Fixing indentation in the yaml
---
.travis.yml | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index b65fdbd..d479758 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,10 +1,10 @@
language: node_js
node_js:
-- 0.8
+ - 0.8
before_script:
-- npm install -g grunt-cli
+ - npm install -g grunt-cli
script: grunt ci --verbose
env:
global:
- - secure: HRae0kyIDDuhonvMi2SfEl1WJb4K/wX8WmzT9YkxFbmWwLjiOMkmqyuEyi76DbTC1cb9o7WwGVgbP1DhSm6n6m0Lz+PSzpprBN4QZuJc56jcc+tBA6gM81hyUufaTT0yUWz112Bu06kWIAs44w5PtG0FYZR0CuIN8fQvZi8fXCQ=
- - secure: c+M5ECIfxDcVrr+ZlqgpGjv8kVM/hxiz3ACMCn4ZkDiaeq4Rw0wWIGZYL6aV5fhsoHgzEQ/XQPca8xKs3Umr7R3b6Vr3AEyFnW+LP67K/1Qbz4Pi3PvhDH/h4rvK7fOoTqTDCVVDEH3v4pefsz2VaKemG4iBKxrcof5aR4Rjopk=
+ - secure: HRae0kyIDDuhonvMi2SfEl1WJb4K/wX8WmzT9YkxFbmWwLjiOMkmqyuEyi76DbTC1cb9o7WwGVgbP1DhSm6n6m0Lz+PSzpprBN4QZuJc56jcc+tBA6gM81hyUufaTT0yUWz112Bu06kWIAs44w5PtG0FYZR0CuIN8fQvZi8fXCQ=
+ - secure: c+M5ECIfxDcVrr+ZlqgpGjv8kVM/hxiz3ACMCn4ZkDiaeq4Rw0wWIGZYL6aV5fhsoHgzEQ/XQPca8xKs3Umr7R3b6Vr3AEyFnW+LP67K/1Qbz4Pi3PvhDH/h4rvK7fOoTqTDCVVDEH3v4pefsz2VaKemG4iBKxrcof5aR4Rjopk=
From da0e4ac0904eab8bc609c10620e19bb1abc0aa91 Mon Sep 17 00:00:00 2001
From: Klaus Hartl
Date: Fri, 9 May 2014 22:08:42 +0200
Subject: [PATCH 70/96] Updating node version to use in CI
---
.travis.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.travis.yml b/.travis.yml
index d479758..bfd8ca1 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,6 +1,6 @@
language: node_js
node_js:
- - 0.8
+ - 0.10
before_script:
- npm install -g grunt-cli
script: grunt ci --verbose
From 1f14c0053ea8f1a77144871ffdc2334a1ea5bbae Mon Sep 17 00:00:00 2001
From: Klaus Hartl
Date: Fri, 9 May 2014 23:22:54 +0200
Subject: [PATCH 71/96] Adding a connect:tests task, to automatically open
tests in the default browser.
Updating grunt-contrib-connect.
---
CONTRIBUTING.md | 6 ++----
Gruntfile.js | 17 ++++++++++++++---
package.json | 2 +-
3 files changed, 17 insertions(+), 8 deletions(-)
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 50ef6d5..7bcfcfa 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -39,11 +39,9 @@ You should see a green message in the console:
You can also run the tests in the browser.
Start a test server from the project root:
- $ grunt connect:server:keepalive
+ $ grunt connect:tests
-Open the following URL in a browser:
-
- $ open http://127.0.0.1:9999/test/index.html
+This will automatically open the tests at http://127.0.0.1:9998/test/index.html in the default browser.
_Note: we recommend cleaning all the browser cookies before running the tests, that can avoid false positive failures._
diff --git a/Gruntfile.js b/Gruntfile.js
index cb0df23..bf0e538 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -49,12 +49,23 @@ module.exports = function (grunt) {
}
},
connect: {
- server: {
+ all: {
options: {
base: '.',
- directory: 'test',
+ directory: 'test'
+ }
+ },
+ saucelabs: {
+ options: {
port: 9999
}
+ },
+ tests: {
+ options: {
+ open: 'http://127.0.0.1:9998/test/index.html',
+ keepalive: true,
+ port: 9998
+ }
}
},
'saucelabs-qunit': {
@@ -160,6 +171,6 @@ module.exports = function (grunt) {
}
grunt.registerTask('default', ['jshint', 'qunit', 'uglify', 'compare_size']);
- grunt.registerTask('saucelabs', ['connect', 'saucelabs-qunit']);
+ grunt.registerTask('saucelabs', ['connect:saucelabs', 'saucelabs-qunit']);
grunt.registerTask('ci', ['jshint', 'qunit', 'saucelabs']);
};
diff --git a/package.json b/package.json
index d52070a..b56857e 100644
--- a/package.json
+++ b/package.json
@@ -25,7 +25,7 @@
"grunt-contrib-watch": "~0.3.0",
"grunt-compare-size": "~0.4.0",
"grunt-saucelabs": "~4.1.1",
- "grunt-contrib-connect": "~0.5.0",
+ "grunt-contrib-connect": "~0.7.1",
"gzip-js": "~0.3.0"
},
"volo": {
From f2b6b252b01cb24a5619744730022d860d3215e1 Mon Sep 17 00:00:00 2001
From: Klaus Hartl
Date: Fri, 9 May 2014 23:49:19 +0200
Subject: [PATCH 72/96] Enable livereload for test suite when opened in the
browser via grunt task
---
CONTRIBUTING.md | 2 +-
Gruntfile.js | 6 +++++-
package.json | 2 +-
3 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 7bcfcfa..7ad0146 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -41,7 +41,7 @@ Start a test server from the project root:
$ grunt connect:tests
-This will automatically open the tests at http://127.0.0.1:9998/test/index.html in the default browser.
+This will automatically open the tests at http://127.0.0.1:9998/test/index.html in the default browser, with livereload enabled.
_Note: we recommend cleaning all the browser cookies before running the tests, that can avoid false positive failures._
diff --git a/Gruntfile.js b/Gruntfile.js
index bf0e538..9751c56 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -29,6 +29,9 @@ module.exports = function (grunt) {
}
},
watch: {
+ options: {
+ livereload: true
+ },
files: [
'jquery.cookie.js',
'test/tests.js'
@@ -62,9 +65,10 @@ module.exports = function (grunt) {
},
tests: {
options: {
+ port: 9998,
open: 'http://127.0.0.1:9998/test/index.html',
keepalive: true,
- port: 9998
+ livereload: true
}
}
},
diff --git a/package.json b/package.json
index b56857e..e865106 100644
--- a/package.json
+++ b/package.json
@@ -22,7 +22,7 @@
"grunt-contrib-jshint": "~0.4.0",
"grunt-contrib-uglify": "~0.2.0",
"grunt-contrib-qunit": "~0.2.0",
- "grunt-contrib-watch": "~0.3.0",
+ "grunt-contrib-watch": "~0.6.1",
"grunt-compare-size": "~0.4.0",
"grunt-saucelabs": "~4.1.1",
"grunt-contrib-connect": "~0.7.1",
From e3a19c3e6dbd7c3ebd4a350bee7d8de1dd4dafed Mon Sep 17 00:00:00 2001
From: Klaus Hartl
Date: Thu, 29 May 2014 00:08:05 +0200
Subject: [PATCH 73/96] Improving Readme
---
README.md | 27 ++++++++++++++++-----------
1 file changed, 16 insertions(+), 11 deletions(-)
diff --git a/README.md b/README.md
index f9a7494..0a6f08e 100644
--- a/README.md
+++ b/README.md
@@ -27,42 +27,47 @@ The plugin can also be loaded as AMD or CommonJS module.
Create session cookie:
```javascript
-$.cookie('the_cookie', 'the_value');
+$.cookie('name', 'value');
```
Create expiring cookie, 7 days from then:
```javascript
-$.cookie('the_cookie', 'the_value', { expires: 7 });
+$.cookie('name', 'value', { expires: 7 });
```
Create expiring cookie, valid across entire site:
```javascript
-$.cookie('the_cookie', 'the_value', { expires: 7, path: '/' });
+$.cookie('name', 'value', { expires: 7, path: '/' });
```
Read cookie:
```javascript
-$.cookie('the_cookie'); // => "the_value"
-$.cookie('not_existing'); // => undefined
+$.cookie('name'); // => "value"
+$.cookie('nothing'); // => undefined
```
Read all available cookies:
```javascript
-$.cookie(); // => { "the_cookie": "the_value", "...remaining": "cookies" }
+$.cookie(); // => { "name": "value" }
```
Delete cookie:
```javascript
-// Returns true when cookie was found, false when no cookie was found...
-$.removeCookie('the_cookie');
-
-// Same path as when the cookie was written...
-$.removeCookie('the_cookie', { path: '/' });
+// Returns true when cookie was successfully deleted, otherwise false
+$.removeCookie('name'); // => true
+$.removeCookie('nothing'); // => false
+
+// Need to use the same attributes (path, domain) as what the cookie was written with
+$.cookie('name', 'value', { path: '/' });
+// This won't work!
+$.removeCookie('name'); // => false
+// This will work!
+$.removeCookie('name', { path: '/' }); // => true
```
*Note: when deleting a cookie, you must pass the exact same path, domain and secure options that were used to set the cookie, unless you're relying on the default options that is.*
From f81174035cc52298efb5a31afc86026516ad29ca Mon Sep 17 00:00:00 2001
From: Klaus Hartl
Date: Fri, 30 May 2014 21:45:19 +0200
Subject: [PATCH 74/96] Updating grunt-saucelabs package.
Required a workaround for exposing test results to the Sauce Labs API.
---
Gruntfile.js | 5 +----
package.json | 2 +-
test/tests.js | 8 ++++++++
3 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/Gruntfile.js b/Gruntfile.js
index 9751c56..5b44abb 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -76,9 +76,7 @@ module.exports = function (grunt) {
all: {
options: {
urls: ['http://127.0.0.1:9999/test/index.html'],
- tunnelTimeout: 5,
build: process.env.TRAVIS_JOB_ID,
- concurrency: 3,
browsers: [
// iOS
{
@@ -160,8 +158,7 @@ module.exports = function (grunt) {
platform: 'Linux',
version: '29'
}
- ],
- testname: 'jquery.cookie qunit tests'
+ ]
}
}
}
diff --git a/package.json b/package.json
index e865106..46c89b5 100644
--- a/package.json
+++ b/package.json
@@ -24,7 +24,7 @@
"grunt-contrib-qunit": "~0.2.0",
"grunt-contrib-watch": "~0.6.1",
"grunt-compare-size": "~0.4.0",
- "grunt-saucelabs": "~4.1.1",
+ "grunt-saucelabs": "~7.0.0",
"grunt-contrib-connect": "~0.7.1",
"gzip-js": "~0.3.0"
},
diff --git a/test/tests.js b/test/tests.js
index bd32552..008f121 100644
--- a/test/tests.js
+++ b/test/tests.js
@@ -1,3 +1,11 @@
+// Required for exposing test results to the Sauce Labs API.
+// Can be removed when the following issue is fixed:
+// https://github.com/axemclion/grunt-saucelabs/issues/84
+QUnit.done(function (details) {
+ window.global_test_results = details;
+});
+
+
var lifecycle = {
teardown: function () {
$.cookie.defaults = {};
From 18fc9a124d377aaea6f90daa29084ad16571ab9b Mon Sep 17 00:00:00 2001
From: Klaus Hartl
Date: Fri, 30 May 2014 22:07:01 +0200
Subject: [PATCH 75/96] Also ignore logs of the form log.1 etc. (created by
Sauce Labs)
---
.gitignore | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.gitignore b/.gitignore
index afea911..15812b0 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,4 @@
node_modules
build
.sizecache.json
-*.log
\ No newline at end of file
+*.log*
From 1a98e9ce0c330d420b70887a02805bb67d0945d8 Mon Sep 17 00:00:00 2001
From: Klaus Hartl
Date: Fri, 30 May 2014 22:13:00 +0200
Subject: [PATCH 76/96] Removing obsolete options for the connect task
---
Gruntfile.js | 6 ------
1 file changed, 6 deletions(-)
diff --git a/Gruntfile.js b/Gruntfile.js
index 5b44abb..2f0906e 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -52,12 +52,6 @@ module.exports = function (grunt) {
}
},
connect: {
- all: {
- options: {
- base: '.',
- directory: 'test'
- }
- },
saucelabs: {
options: {
port: 9999
From 1c710ecf3f3e32c47c8ccf632ac3a8156a4c43f9 Mon Sep 17 00:00:00 2001
From: Klaus Hartl
Date: Fri, 30 May 2014 22:35:42 +0200
Subject: [PATCH 77/96] Updating grunt-contrib-jshint package.
---
Gruntfile.js | 2 +-
package.json | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/Gruntfile.js b/Gruntfile.js
index 2f0906e..3bc12c6 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -15,7 +15,7 @@ module.exports = function (grunt) {
'jquery.cookie.js'
],
options: {
- jshintrc: '.jshintrc'
+ jshintrc: true
}
},
uglify: {
diff --git a/package.json b/package.json
index 46c89b5..b15b7ad 100644
--- a/package.json
+++ b/package.json
@@ -19,7 +19,7 @@
"readmeFilename": "README.md",
"devDependencies": {
"grunt": "~0.4.1",
- "grunt-contrib-jshint": "~0.4.0",
+ "grunt-contrib-jshint": "~0.10.0",
"grunt-contrib-uglify": "~0.2.0",
"grunt-contrib-qunit": "~0.2.0",
"grunt-contrib-watch": "~0.6.1",
From a5aa50fb369bb1b21ba9f928a7da525c6d204061 Mon Sep 17 00:00:00 2001
From: Klaus Hartl
Date: Fri, 30 May 2014 22:57:13 +0200
Subject: [PATCH 78/96] Minimal html for QUnit
---
test/index.html | 11 ++++-------
test/malformed_cookie.html | 2 +-
2 files changed, 5 insertions(+), 8 deletions(-)
diff --git a/test/index.html b/test/index.html
index 814f60c..841310b 100644
--- a/test/index.html
+++ b/test/index.html
@@ -1,19 +1,16 @@
-
+
jquery.cookie Test Suite
-
+
-
-
-
-
-
+
+
diff --git a/test/malformed_cookie.html b/test/malformed_cookie.html
index 3aab83f..17e8db8 100644
--- a/test/malformed_cookie.html
+++ b/test/malformed_cookie.html
@@ -1,4 +1,4 @@
-
+
From 3f1f88b72503e7f993508b2caf37b1d4c0d39f4b Mon Sep 17 00:00:00 2001
From: Klaus Hartl
Date: Sat, 31 May 2014 00:00:56 +0200
Subject: [PATCH 79/96] Also lint tests. For this, moving jshint options into
Gruntfile...
Updated options as well.
---
.jshintrc | 17 -----------------
Gruntfile.js | 54 ++++++++++++++++++++++++++++++++++++++++++++--------
2 files changed, 46 insertions(+), 25 deletions(-)
delete mode 100644 .jshintrc
diff --git a/.jshintrc b/.jshintrc
deleted file mode 100644
index a37f48c..0000000
--- a/.jshintrc
+++ /dev/null
@@ -1,17 +0,0 @@
-{
- "boss": true,
- "browser": true,
- "curly": true,
- "eqeqeq": true,
- "eqnull": true,
- "expr": true,
- "evil": true,
- "newcap": true,
- "noarg": true,
- "undef": true,
- "globals": {
- "define": true,
- "jQuery": true,
- "require": true
- }
-}
diff --git a/Gruntfile.js b/Gruntfile.js
index 3bc12c6..b90568b 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -1,5 +1,3 @@
-/*jshint node: true */
-
'use strict';
module.exports = function (grunt) {
@@ -10,12 +8,52 @@ module.exports = function (grunt) {
all: ['test/index.html']
},
jshint: {
- files: [
- 'Gruntfile.js',
- 'jquery.cookie.js'
- ],
options: {
- jshintrc: true
+ curly: true,
+ eqeqeq: true,
+ expr: true,
+ // maxlen: 130,
+ newcap: true,
+ noarg: true,
+ nonbsp: true,
+ trailing: true,
+ undef: true,
+ unused: true
+ },
+ grunt: {
+ options: {
+ node: true,
+ quotmark: 'single'
+ },
+ files: {
+ src: ['Gruntfile.js']
+ }
+ },
+ source: {
+ options: {
+ browser: true,
+ camelcase: true,
+ jquery: true,
+ quotmark: 'single',
+ globals: {
+ define: true,
+ require: true
+ },
+ },
+ files: {
+ src: ['jquery.cookie.js']
+ }
+ },
+ tests: {
+ options: {
+ browser: true,
+ jquery: true,
+ qunit: true,
+ '-W053': true
+ },
+ files: {
+ src: ['test/**/*.js']
+ }
}
},
uglify: {
@@ -34,7 +72,7 @@ module.exports = function (grunt) {
},
files: [
'jquery.cookie.js',
- 'test/tests.js'
+ 'test/**/*.js'
],
tasks: 'default'
},
From 14557ed5dec32c317bbd426f20e5287a8b9c0f8f Mon Sep 17 00:00:00 2001
From: Klaus Hartl
Date: Mon, 2 Jun 2014 07:40:12 +0200
Subject: [PATCH 80/96] Simplifying test server url...
---
CONTRIBUTING.md | 2 +-
Gruntfile.js | 8 +++++---
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 7ad0146..608c33e 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -41,7 +41,7 @@ Start a test server from the project root:
$ grunt connect:tests
-This will automatically open the tests at http://127.0.0.1:9998/test/index.html in the default browser, with livereload enabled.
+This will automatically open the test suite at http://127.0.0.1:9998 in the default browser, with livereload enabled.
_Note: we recommend cleaning all the browser cookies before running the tests, that can avoid false positive failures._
diff --git a/Gruntfile.js b/Gruntfile.js
index b90568b..fd08089 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -92,13 +92,15 @@ module.exports = function (grunt) {
connect: {
saucelabs: {
options: {
- port: 9999
+ port: 9999,
+ base: ['.', 'test']
}
},
tests: {
options: {
port: 9998,
- open: 'http://127.0.0.1:9998/test/index.html',
+ base: ['.', 'test'],
+ open: 'http://127.0.0.1:9998',
keepalive: true,
livereload: true
}
@@ -107,7 +109,7 @@ module.exports = function (grunt) {
'saucelabs-qunit': {
all: {
options: {
- urls: ['http://127.0.0.1:9999/test/index.html'],
+ urls: ['http://127.0.0.1:9999'],
build: process.env.TRAVIS_JOB_ID,
browsers: [
// iOS
From be47cde2a75446930784fde3e15263974599fd16 Mon Sep 17 00:00:00 2001
From: Krinke
Date: Sat, 12 Jul 2014 11:23:00 -0300
Subject: [PATCH 81/96] Invalid cookie value should not be a getter
Closes gh-308. Closes gh-309.
---
jquery.cookie.js | 2 +-
test/tests.js | 12 ++++++++++++
2 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/jquery.cookie.js b/jquery.cookie.js
index c7f3a59..be1c097 100644
--- a/jquery.cookie.js
+++ b/jquery.cookie.js
@@ -56,7 +56,7 @@
// Write
- if (value !== undefined && !$.isFunction(value)) {
+ if (arguments.length > 1 && !$.isFunction(value)) {
options = $.extend({}, config.defaults, options);
if (typeof options.expires === 'number') {
diff --git a/test/tests.js b/test/tests.js
index 008f121..c016bce 100644
--- a/test/tests.js
+++ b/test/tests.js
@@ -194,6 +194,18 @@ test('number', function () {
strictEqual($.cookie('c'), '1234', 'should write value');
});
+test('null', function () {
+ expect(1);
+ $.cookie('c', null);
+ strictEqual($.cookie('c'), 'null', 'should write value');
+});
+
+test('undefined', function () {
+ expect(1);
+ $.cookie('c', undefined);
+ strictEqual($.cookie('c'), 'undefined', 'should write value');
+});
+
test('expires option as days from now', function () {
expect(1);
var sevenDaysFromNow = new Date();
From b106a0e23640281321cf7ced832f6dc8fb88a085 Mon Sep 17 00:00:00 2001
From: Timo Tijhof
Date: Mon, 14 Jul 2014 21:54:20 +0200
Subject: [PATCH 82/96] Move JSHint config to jshintrc files
Follows-up 3f1f88b725.
Also:
* Moved jquery.cookie.js to src/ directory to allow using a separate
configuration for it (also complements /build, and other jQuery plugin
repositories).
* Simplified Grunt configuration.
---
.jshintignore | 2 +
.jshintrc | 12 +++++
Gruntfile.js | 61 ++++--------------------
bower.json | 2 +-
component.json | 4 +-
src/.jshintrc | 12 +++++
jquery.cookie.js => src/jquery.cookie.js | 0
test/.jshintrc | 9 ++++
test/index.html | 2 +-
test/malformed_cookie.html | 2 +-
10 files changed, 49 insertions(+), 57 deletions(-)
create mode 100644 .jshintignore
create mode 100644 .jshintrc
create mode 100644 src/.jshintrc
rename jquery.cookie.js => src/jquery.cookie.js (100%)
create mode 100644 test/.jshintrc
diff --git a/.jshintignore b/.jshintignore
new file mode 100644
index 0000000..e3fbd98
--- /dev/null
+++ b/.jshintignore
@@ -0,0 +1,2 @@
+build
+node_modules
diff --git a/.jshintrc b/.jshintrc
new file mode 100644
index 0000000..fd016db
--- /dev/null
+++ b/.jshintrc
@@ -0,0 +1,12 @@
+{
+ "curly": true,
+ "eqeqeq": true,
+ "expr": true,
+ // "maxlen": 130,
+ "newcap": true,
+ "noarg": true,
+ "nonbsp": true,
+ "trailing": true,
+ "undef": true,
+ "unused": true
+}
diff --git a/Gruntfile.js b/Gruntfile.js
index fd08089..5ac9db5 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -1,3 +1,4 @@
+/*jshint node:true, quotmark:single */
'use strict';
module.exports = function (grunt) {
@@ -5,56 +6,15 @@ module.exports = function (grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
qunit: {
- all: ['test/index.html']
+ all: 'test/index.html'
},
jshint: {
options: {
- curly: true,
- eqeqeq: true,
- expr: true,
- // maxlen: 130,
- newcap: true,
- noarg: true,
- nonbsp: true,
- trailing: true,
- undef: true,
- unused: true
+ jshintrc: true
},
- grunt: {
- options: {
- node: true,
- quotmark: 'single'
- },
- files: {
- src: ['Gruntfile.js']
- }
- },
- source: {
- options: {
- browser: true,
- camelcase: true,
- jquery: true,
- quotmark: 'single',
- globals: {
- define: true,
- require: true
- },
- },
- files: {
- src: ['jquery.cookie.js']
- }
- },
- tests: {
- options: {
- browser: true,
- jquery: true,
- qunit: true,
- '-W053': true
- },
- files: {
- src: ['test/**/*.js']
- }
- }
+ grunt: 'Gruntfile.js',
+ source: 'src/**/*.js',
+ tests: 'test/**/*.js'
},
uglify: {
options: {
@@ -62,7 +22,7 @@ module.exports = function (grunt) {
},
build: {
files: {
- 'build/jquery.cookie-<%= pkg.version %>.min.js': 'jquery.cookie.js'
+ 'build/jquery.cookie-<%= pkg.version %>.min.js': 'src/jquery.cookie.js'
}
}
},
@@ -70,16 +30,13 @@ module.exports = function (grunt) {
options: {
livereload: true
},
- files: [
- 'jquery.cookie.js',
- 'test/**/*.js'
- ],
+ files: '{src,test}/**/*.js',
tasks: 'default'
},
compare_size: {
files: [
'build/jquery.cookie-<%= pkg.version %>.min.js',
- 'jquery.cookie.js'
+ 'src/jquery.cookie.js'
],
options: {
compress: {
diff --git a/bower.json b/bower.json
index 2d8c25b..3862b74 100644
--- a/bower.json
+++ b/bower.json
@@ -2,7 +2,7 @@
"name": "jquery.cookie",
"version": "1.4.1",
"main": [
- "./jquery.cookie.js"
+ "src/jquery.cookie.js"
],
"dependencies": {
"jquery": ">=1.2"
diff --git a/component.json b/component.json
index 58f79d6..0fad480 100644
--- a/component.json
+++ b/component.json
@@ -7,8 +7,8 @@
"dependencies": {},
"development": {},
"license": "MIT",
- "main": "jquery.cookie.js",
+ "main": "src/jquery.cookie.js",
"scripts": [
- "jquery.cookie.js"
+ "src/jquery.cookie.js"
]
}
diff --git a/src/.jshintrc b/src/.jshintrc
new file mode 100644
index 0000000..dcdf6d6
--- /dev/null
+++ b/src/.jshintrc
@@ -0,0 +1,12 @@
+{
+ "browser": true,
+ "camelcase": true,
+ "jquery": true,
+ "quotmark": "single",
+ "globals": {
+ "define": true,
+ "require": true
+ },
+
+ "extends": "../.jshintrc"
+}
diff --git a/jquery.cookie.js b/src/jquery.cookie.js
similarity index 100%
rename from jquery.cookie.js
rename to src/jquery.cookie.js
diff --git a/test/.jshintrc b/test/.jshintrc
new file mode 100644
index 0000000..bc52b0a
--- /dev/null
+++ b/test/.jshintrc
@@ -0,0 +1,9 @@
+{
+ "browser": true,
+ "jquery": true,
+ "qunit": true,
+
+ "-W053": true,
+
+ "extends": "../.jshintrc"
+}
diff --git a/test/index.html b/test/index.html
index 841310b..ade6830 100644
--- a/test/index.html
+++ b/test/index.html
@@ -6,7 +6,7 @@
-
+
diff --git a/test/malformed_cookie.html b/test/malformed_cookie.html
index 17e8db8..74178d4 100644
--- a/test/malformed_cookie.html
+++ b/test/malformed_cookie.html
@@ -3,7 +3,7 @@
-
+
try {
Object.defineProperty(document, "cookie", { get: function() { return "first=one; ; second=two"; } });
From afc813b033a653999a4d01c11d33626cec346e9f Mon Sep 17 00:00:00 2001
From: Jason Strimpel
Date: Tue, 15 Jul 2014 16:32:45 -0700
Subject: [PATCH 83/96] updated main property value
---
package.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/package.json b/package.json
index b15b7ad..1cd08a6 100644
--- a/package.json
+++ b/package.json
@@ -2,7 +2,7 @@
"name": "jquery.cookie",
"version": "1.4.1",
"description": "A simple, lightweight jQuery plugin for reading, writing and deleting cookies.",
- "main": "jquery.cookie.js",
+ "main": "src/jquery.cookie.js",
"directories": {
"test": "test"
},
From ae467e55ff0ff31d4fe61f92e96cb2377d3e70ad Mon Sep 17 00:00:00 2001
From: Tom Taylor
Date: Wed, 16 Jul 2014 01:05:42 +0100
Subject: [PATCH 84/96] Removed vars, whitespace, 2 bytes saved gzip
---
src/jquery.cookie.js | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/src/jquery.cookie.js b/src/jquery.cookie.js
index be1c097..648a9dd 100644
--- a/src/jquery.cookie.js
+++ b/src/jquery.cookie.js
@@ -75,19 +75,20 @@
// Read
- var result = key ? undefined : {};
+ var result = key ? undefined : {},
// To prevent the for loop in the first place assign an empty array
// in case there are no cookies at all. Also prevents odd result when
// calling $.cookie().
- var cookies = document.cookie ? document.cookie.split('; ') : [];
+ cookies = document.cookie ? document.cookie.split('; ') : [],
+ i = 0, l = cookies.length;
- for (var i = 0, l = cookies.length; i < l; i++) {
- var parts = cookies[i].split('=');
- var name = decode(parts.shift());
- var cookie = parts.join('=');
+ for (; i < l; i++) {
+ var parts = cookies[i].split('='),
+ name = decode(parts.shift()),
+ cookie = parts.join('=');
- if (key && key === name) {
+ if (key === name) {
// If second argument (value) is a function it's a converter...
result = read(cookie, value);
break;
From 9ed982ae82b8204b2d2129f16555cb0b120850ee Mon Sep 17 00:00:00 2001
From: Klaus Hartl
Date: Wed, 16 Jul 2014 07:26:57 +0200
Subject: [PATCH 85/96] Fixing references for a couple of package managers
after moving plugin into src.
See b106a0e23640281321cf7ced832f6dc8fb88a085.
---
package.json | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/package.json b/package.json
index 1cd08a6..38abffe 100644
--- a/package.json
+++ b/package.json
@@ -29,11 +29,11 @@
"gzip-js": "~0.3.0"
},
"volo": {
- "url": "https://raw.github.com/carhartl/jquery-cookie/v{version}/jquery.cookie.js"
+ "url": "https://raw.github.com/carhartl/jquery-cookie/v{version}/src/jquery.cookie.js"
},
"jspm": {
"main": "jquery.cookie",
- "files": ["jquery.cookie.js"],
+ "files": ["src/jquery.cookie.js"],
"buildConfig": {
"uglify": true
}
@@ -42,9 +42,9 @@
"dependencies": {
"jquery": ">=1.2"
},
- "main": "jquery.cookie.js",
+ "main": "src/jquery.cookie.js",
"include": [
- "jquery.cookie.js"
+ "src/jquery.cookie.js"
]
}
}
From aeb793d27286c7f0b915c3aaee24c3b7d04d71fd Mon Sep 17 00:00:00 2001
From: Klaus Hartl
Date: Wed, 16 Jul 2014 07:30:01 +0200
Subject: [PATCH 86/96] Updating copyright
---
src/jquery.cookie.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/jquery.cookie.js b/src/jquery.cookie.js
index be1c097..feb62e9 100644
--- a/src/jquery.cookie.js
+++ b/src/jquery.cookie.js
@@ -2,7 +2,7 @@
* jQuery Cookie Plugin v1.4.1
* https://github.com/carhartl/jquery-cookie
*
- * Copyright 2013 Klaus Hartl
+ * Copyright 2006, 2014 Klaus Hartl
* Released under the MIT license
*/
(function (factory) {
From f12dce392ae87bcc50ee76d57ab8e59f60f522d6 Mon Sep 17 00:00:00 2001
From: Konstantinos Vaggelakos
Date: Wed, 26 Nov 2014 01:56:27 +0100
Subject: [PATCH 87/96] Commonjs export fix and jshint updates
---
.jshintrc | 5 ++++-
src/jquery.cookie.js | 2 +-
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/.jshintrc b/.jshintrc
index fd016db..f3ae239 100644
--- a/.jshintrc
+++ b/.jshintrc
@@ -8,5 +8,8 @@
"nonbsp": true,
"trailing": true,
"undef": true,
- "unused": true
+ "unused": true,
+ "globals": {
+ "module": true
+ }
}
diff --git a/src/jquery.cookie.js b/src/jquery.cookie.js
index feb62e9..2b076a7 100644
--- a/src/jquery.cookie.js
+++ b/src/jquery.cookie.js
@@ -11,7 +11,7 @@
define(['jquery'], factory);
} else if (typeof exports === 'object') {
// CommonJS
- factory(require('jquery'));
+ module.exports = factory(require('jquery'));
} else {
// Browser globals
factory(jQuery);
From 17884203d14afc4eb4954cb8f584c269901756be Mon Sep 17 00:00:00 2001
From: Klaus Hartl
Date: Wed, 18 Mar 2015 21:15:56 +0100
Subject: [PATCH 88/96] Moving around jshint configuration to where it belongs
---
.jshintrc | 5 +----
src/.jshintrc | 1 +
2 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/.jshintrc b/.jshintrc
index f3ae239..fd016db 100644
--- a/.jshintrc
+++ b/.jshintrc
@@ -8,8 +8,5 @@
"nonbsp": true,
"trailing": true,
"undef": true,
- "unused": true,
- "globals": {
- "module": true
- }
+ "unused": true
}
diff --git a/src/.jshintrc b/src/.jshintrc
index dcdf6d6..241dd9f 100644
--- a/src/.jshintrc
+++ b/src/.jshintrc
@@ -5,6 +5,7 @@
"quotmark": "single",
"globals": {
"define": true,
+ "module": true,
"require": true
},
From 8b28ab2091e966b78f8d901df02e317e00bcde6b Mon Sep 17 00:00:00 2001
From: Klaus Hartl
Date: Wed, 18 Mar 2015 21:17:11 +0100
Subject: [PATCH 89/96] Improving comments somewhat
---
src/jquery.cookie.js | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/jquery.cookie.js b/src/jquery.cookie.js
index 2b076a7..8deb387 100644
--- a/src/jquery.cookie.js
+++ b/src/jquery.cookie.js
@@ -7,10 +7,10 @@
*/
(function (factory) {
if (typeof define === 'function' && define.amd) {
- // AMD
+ // AMD (Register as an anonymous module)
define(['jquery'], factory);
} else if (typeof exports === 'object') {
- // CommonJS
+ // Node/CommonJS
module.exports = factory(require('jquery'));
} else {
// Browser globals
From 07e593d8fb8913867e357b6ddee3f7f6a05c35e7 Mon Sep 17 00:00:00 2001
From: Klaus Hartl
Date: Wed, 18 Mar 2015 21:34:39 +0100
Subject: [PATCH 90/96] Trying to improve readability a bit
---
src/jquery.cookie.js | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/jquery.cookie.js b/src/jquery.cookie.js
index 5b0f45d..3f5a205 100644
--- a/src/jquery.cookie.js
+++ b/src/jquery.cookie.js
@@ -76,12 +76,12 @@
// Read
var result = key ? undefined : {},
-
- // To prevent the for loop in the first place assign an empty array
- // in case there are no cookies at all. Also prevents odd result when
- // calling $.cookie().
+ // To prevent the for loop in the first place assign an empty array
+ // in case there are no cookies at all. Also prevents odd result when
+ // calling $.cookie().
cookies = document.cookie ? document.cookie.split('; ') : [],
- i = 0, l = cookies.length;
+ i = 0,
+ l = cookies.length;
for (; i < l; i++) {
var parts = cookies[i].split('='),
From 41b1bad52a029e75f68676024a559dd0142fcb67 Mon Sep 17 00:00:00 2001
From: Klaus Hartl
Date: Wed, 18 Mar 2015 22:04:51 +0100
Subject: [PATCH 91/96] Fix computation of the expires date to consider a local
daylight saving time change
Avoid being too clever, using Date.setTime() that is.
Fixes #331.
---
src/jquery.cookie.js | 2 +-
test/tests.js | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/jquery.cookie.js b/src/jquery.cookie.js
index 3f5a205..393c01d 100644
--- a/src/jquery.cookie.js
+++ b/src/jquery.cookie.js
@@ -61,7 +61,7 @@
if (typeof options.expires === 'number') {
var days = options.expires, t = options.expires = new Date();
- t.setTime(+t + days * 864e+5);
+ t.setMilliseconds(t.getMilliseconds() + days * 864e+5);
}
return (document.cookie = [
diff --git a/test/tests.js b/test/tests.js
index c016bce..5f1a1f1 100644
--- a/test/tests.js
+++ b/test/tests.js
@@ -209,8 +209,8 @@ test('undefined', function () {
test('expires option as days from now', function () {
expect(1);
var sevenDaysFromNow = new Date();
- sevenDaysFromNow.setDate(sevenDaysFromNow.getDate() + 7);
- strictEqual($.cookie('c', 'v', { expires: 7 }), 'c=v; expires=' + sevenDaysFromNow.toUTCString(),
+ sevenDaysFromNow.setDate(sevenDaysFromNow.getDate() + 21);
+ strictEqual($.cookie('c', 'v', { expires: 21 }), 'c=v; expires=' + sevenDaysFromNow.toUTCString(),
'should write the cookie string with expires');
});
From 4527b3725ce7b61066e6aa12bbe8d20c0371a1d7 Mon Sep 17 00:00:00 2001
From: Klaus Hartl
Date: Wed, 18 Mar 2015 22:26:54 +0100
Subject: [PATCH 92/96] Fix removing cookies in sub paths
When trying to remove a cookie in a sub path (defined via path), we can't
first try to read the cookie in a guard clause, it won't be readable
and thus the removal was not even attempted. So I'm removing the guard
clause entirely. On second thought its return value was also wrong anyway:
when attempting to remove a non-existing cookie, after the removal it still
doesn't exist and the removeCookie() should therefore return false.
Closes #336.
---
src/jquery.cookie.js | 4 ----
test/tests.js | 10 +++++-----
2 files changed, 5 insertions(+), 9 deletions(-)
diff --git a/src/jquery.cookie.js b/src/jquery.cookie.js
index 393c01d..8218817 100644
--- a/src/jquery.cookie.js
+++ b/src/jquery.cookie.js
@@ -106,10 +106,6 @@
config.defaults = {};
$.removeCookie = function (key, options) {
- if ($.cookie(key) === undefined) {
- return false;
- }
-
// Must not alter options, thus extending a fresh object...
$.cookie(key, '', $.extend({}, options, { expires: -1 }));
return !$.cookie(key);
diff --git a/test/tests.js b/test/tests.js
index 5f1a1f1..68b47cc 100644
--- a/test/tests.js
+++ b/test/tests.js
@@ -282,6 +282,11 @@ test('when sucessfully deleted', function () {
strictEqual($.removeCookie('c'), true, 'returns true');
});
+test('when cookie does not exist', function () {
+ expect(1);
+ strictEqual($.removeCookie('c'), true, 'returns true');
+});
+
test('when deletion failed', function () {
expect(1);
$.cookie('c', 'v');
@@ -299,11 +304,6 @@ test('when deletion failed', function () {
$.cookie = originalCookie;
});
-test('when cookie does not exist', function () {
- expect(1);
- strictEqual($.removeCookie('c'), false, 'returns false');
-});
-
test('with options', function () {
expect(1);
var options = { path: '/' };
From 6d5b9190b446b68e13b45d0b7d78c7ba4a62cb65 Mon Sep 17 00:00:00 2001
From: Fagner Brack
Date: Thu, 9 Apr 2015 03:48:53 -0300
Subject: [PATCH 93/96] Add notice
---
README.md | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/README.md b/README.md
index 0a6f08e..4633b97 100644
--- a/README.md
+++ b/README.md
@@ -1,3 +1,11 @@
+# IMPORTANT!
+
+This project is being moved to [Javascript Cookie](https://github.com/js-cookie/js-cookie), an implementation of jquery-cookie without jQuery.
+
+For more information check [the discussion](https://github.com/carhartl/jquery-cookie/issues/349).
+
+New issues should be opened in [js-cookie bug tracker](https://github.com/js-cookie/js-cookie/issues).
+
# jquery.cookie [](https://travis-ci.org/carhartl/jquery-cookie) [](https://codeclimate.com/github/carhartl/jquery-cookie)
A simple, lightweight jQuery plugin for reading, writing and deleting cookies.
From 06e4e3a1d189bb18356c3aa337b055166a52916e Mon Sep 17 00:00:00 2001
From: Klaus Hartl
Date: Sat, 18 Apr 2015 09:58:51 +0200
Subject: [PATCH 94/96] Correct spelling
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 4633b97..47198c6 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
# IMPORTANT!
-This project is being moved to [Javascript Cookie](https://github.com/js-cookie/js-cookie), an implementation of jquery-cookie without jQuery.
+This project is being moved to [JavaScript Cookie](https://github.com/js-cookie/js-cookie), an implementation of jquery-cookie without jQuery.
For more information check [the discussion](https://github.com/carhartl/jquery-cookie/issues/349).
From 636c27d72cc1e4eec53fade4f74f4b35570cd6b8 Mon Sep 17 00:00:00 2001
From: Fagner Brack
Date: Sat, 25 Apr 2015 11:10:33 -0300
Subject: [PATCH 95/96] Make the notice clearer and more direct
Also provide the latest backwards compatible release link in the bold section
---
README.md | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/README.md b/README.md
index 47198c6..59ebd16 100644
--- a/README.md
+++ b/README.md
@@ -1,17 +1,13 @@
# IMPORTANT!
-This project is being moved to [JavaScript Cookie](https://github.com/js-cookie/js-cookie), an implementation of jquery-cookie without jQuery.
-
-For more information check [the discussion](https://github.com/carhartl/jquery-cookie/issues/349).
-
-New issues should be opened in [js-cookie bug tracker](https://github.com/js-cookie/js-cookie/issues).
+This project was moved to https://github.com/js-cookie/js-cookie, check [the discussion](https://github.com/carhartl/jquery-cookie/issues/349).
# jquery.cookie [](https://travis-ci.org/carhartl/jquery-cookie) [](https://codeclimate.com/github/carhartl/jquery-cookie)
A simple, lightweight jQuery plugin for reading, writing and deleting cookies.
-**If you're viewing this at https://github.com/carhartl/jquery-cookie, you're reading the documentation for the master branch.
-[View documentation for the latest release (1.4.1).](https://github.com/carhartl/jquery-cookie/tree/v1.4.1)**
+**If you're viewing this, you're reading the documentation for the old repository.
+[View documentation for the latest backwards compatible release (1.5.1).](https://github.com/js-cookie/js-cookie/tree/v1.5.1)**
## Build Status Matrix
From d72bb07e29962330db61aae1eda07f6312419840 Mon Sep 17 00:00:00 2001
From: Fagner Brack
Date: Wed, 27 May 2015 12:36:08 -0300
Subject: [PATCH 96/96] Make it clear where to open new issues
It was added in https://github.com/carhartl/jquery-cookie/commit/6d5b9190b446b68e13b45d0b7d78c7ba4a62cb65 but removed in https://github.com/carhartl/jquery-cookie/commit/636c27d72cc1e4eec53fade4f74f4b35570cd6b8.
Adding it again since 2 new issues were created after the removal: gh-362, gh-363
---
README.md | 2 ++
1 file changed, 2 insertions(+)
diff --git a/README.md b/README.md
index 59ebd16..3100800 100644
--- a/README.md
+++ b/README.md
@@ -2,6 +2,8 @@
This project was moved to https://github.com/js-cookie/js-cookie, check [the discussion](https://github.com/carhartl/jquery-cookie/issues/349).
+New issues should be opened at https://github.com/js-cookie/js-cookie/issues
+
# jquery.cookie [](https://travis-ci.org/carhartl/jquery-cookie) [](https://codeclimate.com/github/carhartl/jquery-cookie)
A simple, lightweight jQuery plugin for reading, writing and deleting cookies.