Windshaft-cartodb/lib/models/layergroup-token.js

32 lines
714 B
JavaScript
Raw Normal View History

'use strict';
2015-07-08 05:46:58 +08:00
/**
* @param {String} token might match the following pattern: {user}@{tpl_id}@{token}:{cache_buster}
*/
2019-10-22 01:07:24 +08:00
function parse (token) {
2015-07-08 05:46:58 +08:00
var signer, cacheBuster;
var tokenSplit = token.split(':');
token = tokenSplit[0];
if (tokenSplit.length > 1) {
cacheBuster = tokenSplit[1];
}
tokenSplit = token.split('@');
2019-10-22 01:07:24 +08:00
if (tokenSplit.length > 1) {
2015-07-08 05:46:58 +08:00
signer = tokenSplit.shift();
2019-10-22 01:07:24 +08:00
if (tokenSplit.length > 1) {
/* var template_hash = */tokenSplit.shift(); // unused
2015-07-08 05:46:58 +08:00
}
token = tokenSplit.shift();
}
return {
token: token,
signer: signer,
cacheBuster: cacheBuster
};
}
module.exports.parse = parse;