2017-03-19 00:43:14 +01:00
|
|
|
var hash_util = (function () {
|
|
|
|
|
|
|
|
var exports = {};
|
|
|
|
|
|
|
|
// Some browsers zealously URI-decode the contents of
|
|
|
|
// window.location.hash. So we hide our URI-encoding
|
|
|
|
// by replacing % with . (like MediaWiki).
|
|
|
|
exports.encodeHashComponent = function (str) {
|
|
|
|
return encodeURIComponent(str)
|
|
|
|
.replace(/\./g, '%2E')
|
2017-10-18 19:16:41 +02:00
|
|
|
.replace(/%/g, '.');
|
2017-03-19 00:43:14 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
exports.encode_operand = function (operator, operand) {
|
2017-06-04 01:51:53 +02:00
|
|
|
if ((operator === 'group-pm-with') || (operator === 'pm-with') || (operator === 'sender')) {
|
2017-03-19 00:43:14 +01:00
|
|
|
var slug = people.emails_to_slug(operand);
|
|
|
|
if (slug) {
|
|
|
|
return slug;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return exports.encodeHashComponent(operand);
|
|
|
|
};
|
|
|
|
|
|
|
|
exports.decodeHashComponent = function (str) {
|
|
|
|
return decodeURIComponent(str.replace(/\./g, '%'));
|
|
|
|
};
|
|
|
|
|
|
|
|
exports.decode_operand = function (operator, operand) {
|
2017-06-04 01:51:53 +02:00
|
|
|
if ((operator === 'group-pm-with') || (operator === 'pm-with') || (operator === 'sender')) {
|
2017-03-19 00:43:14 +01:00
|
|
|
var emails = people.slug_to_emails(operand);
|
|
|
|
if (emails) {
|
|
|
|
return emails;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return exports.decodeHashComponent(operand);
|
|
|
|
};
|
|
|
|
|
|
|
|
return exports;
|
|
|
|
|
|
|
|
}());
|
|
|
|
if (typeof module !== 'undefined') {
|
|
|
|
module.exports = hash_util;
|
|
|
|
}
|