UNPKG

is-same-origin

Version:

Check if two URLs are same origin, for Node and the browser

5 lines 584 B
/** @license is-same-origin v0.0.7 * Copyright (c) 2018-present, Qingrong Ke <keqingrong1992@gmail.com> (https://keqingrong.github.io/) * Released under the MIT license */ !function(o,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):o.isSameOrigin=e()}(this,function(){"use strict";function o(o){var e=null;try{e=new URL(o)}catch(o){console.error(o)}return e}return function(e,n){var t=o(e),r=o(n);return!(!t||!r)&&(t.origin===r.origin||t.protocol===r.protocol&&t.hostname===r.hostname&&t.port===r.port)}});