Repository URL to install this package:
|
Version:
1.0.10 ▾
|
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const exotic_1 = require("exotic");
/**
* @todo - wonder if this should be in view layer in the atom?
*/
const toHTTPS = (url) => {
return url.includes('https://') === true
? url
: url.replace(/http:\/\//gim, 'https://');
};
exports.toHTTPS = toHTTPS;
// const IMAGE_PROPS_LIST = ['src', 'url', 'image', 'value']
// const toFirstImagePropFound = coerceFirstPropFor(IMAGE_PROPS_LIST)
const fromUnsecureToSecureImage = (image) => {
if (exotic_1.isString(image)) {
return toHTTPS(image);
}
else if (exotic_1.isObj(image)) {
// @todo modules/compose oneOf
// const alt = name || item.alt || props.label || ''
if (exotic_1.isString(image.src) === true) {
image.src = toHTTPS(image.src);
}
else if (exotic_1.isString(image.url) === true) {
image.url = toHTTPS(image.url);
}
else if (exotic_1.isString(image.value) === true) {
image.value = toHTTPS(image.value);
}
// @todo enable
// const url = image.src || image.url || image.image || image.value || ''
// const [prop, value] = toFirstImagePropFound(image)
// image[prop] = toHTTPS(value)
return image;
}
else {
// throw new TypeError
return image;
}
};
exports.fromUnsecureToSecureImage = fromUnsecureToSecureImage;
exports.toSecureProtocol = fromUnsecureToSecureImage;
exports.default = fromUnsecureToSecureImage;
//# sourceMappingURL=toSecureProtocol.js.map