1
0
mirror of https://github.com/moparisthebest/mail synced 2024-12-22 23:38:48 -05:00

Use regex to parse key server urls from manifest

This commit is contained in:
Tankred Hase 2014-10-22 19:42:56 +02:00
parent c6b50d04f6
commit eb81028123
2 changed files with 9 additions and 13 deletions

View File

@ -1,6 +1,5 @@
{
"name": "whiteout-mail",
"version": "0.0.1",
"description": "Mail App with integrated OpenPGP encryption.",
"author": "Whiteout Networks",
"homepage": "https://whiteout.io",

View File

@ -164,21 +164,18 @@ if (typeof chrome !== 'undefined' && chrome.runtime && chrome.runtime.getManifes
}
function setConfigParams(manifest) {
var cfg = exports.config,
cloudUrl, keychainUrl;
var cfg = exports.config;
function getUrl(beginsWith) {
return _.find(manifest.permissions, function(permission) {
return typeof permission === 'string' && permission.indexOf(beginsWith) === 0;
}).replace(/\/$/, ''); // remove last '/' from url due to required syntax in manifest
}
// get key server base url
cloudUrl = _.find(manifest.permissions, function(permission) {
return typeof permission === 'string' && permission.indexOf('https://keys') === 0;
});
// remove last '/' from url due to required syntax in manifest
cfg.cloudUrl = cloudUrl.substring(0, cloudUrl.length - 1);
cfg.cloudUrl = getUrl('https://keys');
// get keychain server base url
keychainUrl = _.find(manifest.permissions, function(permission) {
return typeof permission === 'string' && permission.indexOf('https://keychain') === 0;
});
// remove last '/' from url due to required syntax in manifest
cfg.privkeyServerUrl = keychainUrl.substring(0, keychainUrl.length - 1);
cfg.privkeyServerUrl = getUrl('https://keychain');
// get client ID for OAuth requests
cfg.gmail.clientId = manifest.oauth2.client_id;
// get the app version