UNPKG

@barchart/common-js

Version:
31 lines (25 loc) 665 B
import * as is from './../is.js'; /** * Determines whether the current browser context is using a secure protocol. * * @public * @param {boolean=} secure * @returns {boolean} */ export function getIsSecure(secure) { let returnVal; if (is.boolean(secure)) { returnVal = secure; } else { let protocol; if (window && window.location && is.string(window.location.protocol)) { protocol = window.location.protocol; } else if (document && document.location && is.string(document.location.protocol)) { protocol = document.location.protocol; } else { protocol = ''; } returnVal = protocol.indexOf('https') === 0; } return returnVal; }