@mediarithmics/plugins-nodejs-sdk
Version:
This is the mediarithmics nodejs to help plugin developers bootstrapping their plugin without having to deal with most of the plugin boilerplate
25 lines • 896 B
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.generateEncodedClickUrl = void 0;
const lodash_1 = __importDefault(require("lodash"));
function generateEncodedClickUrl(redirectUrls) {
const urls = lodash_1.default.clone(redirectUrls);
return urls.reduceRight((acc, current, index) => {
if (index == urls.length - 1) {
return current.url;
}
return current.url + encodeUrlInfo(acc, current.redirect_count);
}, '');
}
exports.generateEncodedClickUrl = generateEncodedClickUrl;
function encodeUrlInfo(url, redirectCount) {
while (redirectCount > 0) {
url = encodeURIComponent(url);
redirectCount--;
}
return url;
}
//# sourceMappingURL=index.js.map