diff options
author | Christopher Lenz <cmlenz@apache.org> | 2010-01-20 22:42:10 +0000 |
---|---|---|
committer | Christopher Lenz <cmlenz@apache.org> | 2010-01-20 22:42:10 +0000 |
commit | 6ac2a044263f50c48f101af3f9df4a47fe823003 (patch) | |
tree | e95597791e0bc8f4117feed9e8c78480eee4ee4e /share/www | |
parent | 55515caffa246e0739ef90a3a3443a5bd5c2b223 (diff) |
Futon: Prefix cookie names with the port number, so that different CouchDB instances accessed through the same host name but different ports get their own storage. Closes COUCHDB-533.
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@901413 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'share/www')
-rw-r--r-- | share/www/script/futon.js | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/share/www/script/futon.js b/share/www/script/futon.js index ce7de02e..005fe032 100644 --- a/share/www/script/futon.js +++ b/share/www/script/futon.js @@ -160,7 +160,8 @@ } this.addDatabase = function(name) { - var recentDbs = $.futon.storage.get("recent", "").split(","); + var current = $.futon.storage.get("recent", ""); + var recentDbs = current ? current.split(",") : []; if ($.inArray(name, recentDbs) == -1) { recentDbs.unshift(name); if (recentDbs.length > 10) recentDbs.length = 10; @@ -171,7 +172,8 @@ this.removeDatabase = function(name) { // remove database from recent databases list - var recentDbs = $.futon.storage.get("recent").split(","); + var current = $.futon.storage.get("recent", ""); + var recentDbs = current ? current.split(",") : []; var recentIdx = $.inArray(name, recentDbs); if (recentIdx >= 0) { recentDbs.splice(recentIdx, 1); @@ -309,11 +311,14 @@ return callback(decl); } + // add suffix to cookie names to be able to separate between ports + var cookiePrefix = location.port + "_"; + var handlers = { "cookie": { get: function(name) { - var nameEq = name + "="; + var nameEq = cookiePrefix + name + "="; var parts = document.cookie.split(';'); for (var i = 0; i < parts.length; i++) { var part = parts[i].replace(/^\s+/, ""); @@ -325,13 +330,14 @@ set: function(name, value) { var date = new Date(); date.setTime(date.getTime() + 14*24*60*60*1000); // two weeks - document.cookie = name + "=" + escape(value) + "; expires=" + - date.toGMTString(); + document.cookie = cookiePrefix + name + "=" + escape(value) + + "; domain=" + location.hostname + "; expires=" + date.toGMTString(); }, del: function(name) { var date = new Date(); date.setTime(date.getTime() - 24*60*60*1000); // yesterday - document.cookie = name + "=; expires=" + date.toGMTString(); + document.cookie = cookiePrefix + name + "=; domain=" + + location.hostname + "; expires=" + date.toGMTString(); } }, |