Skip to content
This repository has been archived by the owner on Nov 25, 2024. It is now read-only.

Commit

Permalink
Closes #2. Cookie is now set on safari
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanramage committed Aug 5, 2013
1 parent 16a7beb commit 613407f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/dashboards.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ exports.detectLocal = function () {
};

exports.readCookie = function () {
var value = cookies.readBrowserCookie('_dashboard_urls');
var value = cookies.readCookie('_dashboard_urls');
if (value) {
var durls = JSON.parse(unescape(value));
exports._dashboard_urls = _.uniq(exports._dashboard_urls.concat(durls));
Expand All @@ -45,7 +45,7 @@ exports.updateCookie = function () {
cookies.setBrowserCookie(null, {
name: '_dashboard_urls',
value: JSON.stringify(exports._dashboard_urls),
path: dutils.getBaseURL()
path: '/'
});
};

Expand Down
13 changes: 12 additions & 1 deletion packages/cookies/cookies.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,18 @@ exports.readBrowserCookies = function () {
return cookies;
};

exports.readCookie = function(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for (var i = 0; i < ca.length; i++) {
var c = ca[i];
while (c.charAt(0) == ' ') c = c.substring(1, c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
}
return null;
}


/**
* Reads browser cookies and returned the value of the named cookie.
*
Expand Down Expand Up @@ -81,7 +93,6 @@ exports.setBrowserCookie = function (req, opt) {
throw new Error('setBrowserCookie cannot be called server-side');
}
var str = (typeof opt === 'string') ? opt: exports.cookieString(req, opt);
//console.log('document.cookie = ' + str);
document.cookie = str;
};

Expand Down

0 comments on commit 613407f

Please sign in to comment.