UNPKG

safe-open

Version:

A small utility to safely open URLs, upgrading http to https when necessary.

2 lines 299 B
function i(t,n="_blank",o){if(typeof window>"u"||typeof window.open!="function"||!t||typeof t!="string")return null;let e=window.location.protocol==="https:"&&t.startsWith("http://")?t.replace(/^http:/,"https:"):t;return window.open(e,n,o)}/* istanbul ignore if -- @preserve */ export{i as default};