Bug 1814893 - Clean up uris.sys.mjs. r=kaie
Differential Revision: https://phabricator.services.mozilla.com/D206605 --HG-- extra : rebase_source : d51dd913e746c81a1dba6d997671030c175ad173
This commit is contained in:
Родитель
3098589bfe
Коммит
ea7e95f75d
|
@ -4,65 +4,41 @@
|
|||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
const lazy = {};
|
||||
|
||||
ChromeUtils.defineESModuleGetters(lazy, {
|
||||
EnigmailLog: "chrome://openpgp/content/modules/log.sys.mjs",
|
||||
});
|
||||
|
||||
const encryptedUris = [];
|
||||
const encryptedUris = new Set();
|
||||
|
||||
export var EnigmailURIs = {
|
||||
/*
|
||||
* remember the fact a URI is encrypted
|
||||
/**
|
||||
* Remember the fact a URI is encrypted.
|
||||
*
|
||||
* @param String msgUri
|
||||
*
|
||||
* @return null
|
||||
* @param {string} uri
|
||||
*/
|
||||
rememberEncryptedUri(uri) {
|
||||
lazy.EnigmailLog.DEBUG(
|
||||
"uris.sys.mjs: rememberEncryptedUri: uri=" + uri + "\n"
|
||||
);
|
||||
if (!encryptedUris.includes(uri)) {
|
||||
encryptedUris.push(uri);
|
||||
}
|
||||
encryptedUris.add(uri);
|
||||
},
|
||||
|
||||
/*
|
||||
* unremember the fact a URI is encrypted
|
||||
/**
|
||||
* Unremember/forget the fact a URI is encrypted.
|
||||
*
|
||||
* @param String msgUri
|
||||
*
|
||||
* @return null
|
||||
* @param {string} uri
|
||||
*/
|
||||
forgetEncryptedUri(uri) {
|
||||
lazy.EnigmailLog.DEBUG(
|
||||
"uris.sys.mjs: forgetEncryptedUri: uri=" + uri + "\n"
|
||||
);
|
||||
const pos = encryptedUris.indexOf(uri);
|
||||
if (pos >= 0) {
|
||||
encryptedUris.splice(pos, 1);
|
||||
}
|
||||
encryptedUris.delete(uri);
|
||||
},
|
||||
|
||||
/*
|
||||
* determine if a URI was remembered as encrypted
|
||||
/**
|
||||
* Determine if a URI was remembered as encrypted.
|
||||
*
|
||||
* @param String msgUri
|
||||
*
|
||||
* @return: Boolean true if yes, false otherwise
|
||||
* @param {string} uri
|
||||
* @return {boolean} true if yes, false otherwise.
|
||||
*/
|
||||
isEncryptedUri(uri) {
|
||||
lazy.EnigmailLog.DEBUG("uris.sys.mjs: isEncryptedUri: uri=" + uri + "\n");
|
||||
return encryptedUris.includes(uri);
|
||||
return encryptedUris.has(uri);
|
||||
},
|
||||
|
||||
/**
|
||||
* Determine message number and folder from mailnews URI.
|
||||
*
|
||||
* @param {nsIURI} url - nsIURI object.
|
||||
*
|
||||
* @param {nsIURI} url - nsIURI of the message.
|
||||
* @returns {?object} obj
|
||||
* @returns {string} obj.msgNum - The message number, or "" if no URI scheme fits.
|
||||
* @returns {string} obj.folder - The folder (or newsgroup) name.
|
||||
|
@ -80,12 +56,6 @@ export var EnigmailURIs = {
|
|||
return null;
|
||||
}
|
||||
|
||||
lazy.EnigmailLog.DEBUG(
|
||||
"uris.sys.mjs: msgIdentificationFromUrl: url.pathQueryRef=" +
|
||||
("path" in url ? url.path : url.pathQueryRef) +
|
||||
"\n"
|
||||
);
|
||||
|
||||
let msgNum = "";
|
||||
let msgFolder = "";
|
||||
|
||||
|
@ -106,14 +76,6 @@ export var EnigmailURIs = {
|
|||
msgFolder = pathQueryRef.replace(/(.*[?&]group=)([^&]+)(&.*)?/, "$2");
|
||||
}
|
||||
|
||||
lazy.EnigmailLog.DEBUG(
|
||||
"uris.sys.mjs: msgIdentificationFromUrl: msgNum=" +
|
||||
msgNum +
|
||||
" / folder=" +
|
||||
msgFolder +
|
||||
"\n"
|
||||
);
|
||||
|
||||
return {
|
||||
msgNum,
|
||||
folder: msgFolder.toLowerCase(),
|
||||
|
|
Загрузка…
Ссылка в новой задаче