code: function urlIsSameOrigin(url) {
    if (typeof document !== 'undefined') {
      // for IE really
      const a = document.createElement('a');
      a.href = url;
      return a.hostname === location.hostname &&
             a.port     === location.port &&
             a.protocol === location.protocol;
    } else {
      const localOrigin = (new URL(location.href)).origin;
      const urlOrigin = (new URL(url, location.href)).origin;
      return urlOrigin === localOrigin;
    }
  }
docs: Checks whether the url's origin is the same so that we can set the `crossOrigin`
  @param {string} url url to image
  @returns {boolean} true if the window's origin is the same as image's url
  @private