function checkPossibleFailReasons()

in src/core/plugins/download-url.js [41:71]


      function checkPossibleFailReasons() {
        try {
          let specUrl

          if("URL" in win ) {
            specUrl = new URL(url)
          } else {
            // legacy browser, use <a href> to parse the URL
            specUrl = document.createElement("a")
            specUrl.href = url
          }

          if(specUrl.protocol !== "https:" && win.location.protocol === "https:") {
            const error = Object.assign(
              new Error(`Possible mixed-content issue? The page was loaded over https:// but a ${specUrl.protocol}// URL was specified. Check that you are not attempting to load mixed content.`),
              {source: "fetch"}
            )
            errActions.newThrownErr(error)
            return
          }
          if(specUrl.origin !== win.location.origin) {
            const error = Object.assign(
              new Error(`Possible cross-origin (CORS) issue? The URL origin (${specUrl.origin}) does not match the page (${win.location.origin}). Check the server returns the correct 'Access-Control-Allow-*' headers.`),
              {source: "fetch"}
            )
            errActions.newThrownErr(error)
          }
        } catch (e) {
          return
        }
      }