Repository URL to install this package:
|
Version:
1.2.18 ▾
|
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.toHTTPS = exports.toSecureProtocol = exports.fromUnsecureToSecureImage = exports.default = void 0;
var _exotic = require("exotic");
/* @lint readable tree */
/* eslint-disable brace-style */
/**
* @todo - wonder if this should be in view layer in the atom?
* @param {string} url
* @return {string}
*/
const toHTTPS = url => {
return url.includes('https://') === true ? url : url.replace(/http:\/\//gmi, 'https://');
}; // const IMAGE_PROPS_LIST = ['src', 'url', 'image', 'value']
// const toFirstImagePropFound = coerceFirstPropFor(IMAGE_PROPS_LIST)
exports.toHTTPS = toHTTPS;
const fromUnsecureToSecureImage = image => {
if ((0, _exotic.isString)(image) === true) {
return toHTTPS(image);
} else if ((0, _exotic.isObj)(image) === true) {
// @todo modules/compose oneOf
// const alt = name || item.alt || props.label || ''
if ((0, _exotic.isString)(image.src) === true) {
image.src = toHTTPS(image.src);
} else if ((0, _exotic.isString)(image.url) === true) {
image.url = toHTTPS(image.url);
} else if ((0, _exotic.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.toSecureProtocol = exports.fromUnsecureToSecureImage = fromUnsecureToSecureImage;
var _default = fromUnsecureToSecureImage;
exports.default = _default;