function settingsToStorage(settings) {
var s = [];
$.each(settings, function (key, value) {
s.push(key + "=" + encodeURIComponent(value));
})
return s.join("&");
}
function settingsFromStorage(storage) {
var settings = {};
storage.replace(/[#&]+([^=&]+)=([^&]*)/gi, function (m, key, value) { settings[key] = decodeURIComponent(value); });
return settings;
}
Nice one, I think ill use it!
ReplyDeleteFor anyone else stumbling onto this, you'll need to add a call to decodeURIComponent() in settingsFromStorage() when setting the value.
@Craig,
ReplyDeleteUpdated. Nice find, thanks.