{"version":3,"sources":["jsdelivr-header.js","/npm/page-icon@0.4.0/src/index.js"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,ACNA,MAAM,IAAM,QAAQ,OAEd,cAAgB,QAAQ,mBACxB,aAAe,QAAQ,kBACvB,aAAe,QAAQ,kBACvB,QAAU,QAAQ,aAExB,SAAS,QAAQ,GACf,MAAuC,WAAhC,IAAI,MAAM,GAAS,QAC5B,CAEA,SAAS,UAAU,GACjB,MAAM,EAAS,IAAI,MAAM,GAEzB,OADA,EAAO,SAAW,SACX,IAAI,OAAO,EACpB,CAEA,SAAS,KAAK,EAAS,EAAQ,CAAC,GAM9B,OAAO,QAAQ,GACd,MAAK,SAAU,GACd,OAAO,aAAa,EAAS,EAC/B,IACC,KAAK,eACL,MAToB,SAAS,GAC5B,OAAO,aAAa,EAAO,EAAQ,IACrC,IAQC,MAAK,IACJ,GAAI,GAAU,QAAQ,GACpB,OAAO,EAIT,OAAO,KADU,UAAU,GACL,EAAQ,GAElC,CAEA,OAAO,QAAU","file":"/npm/page-icon@0.4.0/src/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/page-icon@0.4.0/src/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","const url = require('url');\n\nconst downloadIcons = require('./downloadIcons');\nconst findBestIcon = require('./findBestIcon');\nconst getIconLinks = require('./getIconLinks');\nconst getPage = require('./getPage');\n\nfunction isHttps(pageUrl) {\n  return url.parse(pageUrl).protocol === 'https:';\n}\n\nfunction makeHttps(pageUrl) {\n  const parsed = url.parse(pageUrl);\n  parsed.protocol = 'https:';\n  return url.format(parsed);\n}\n\nfunction main(pageUrl, options={}) {\n\n  const bestWithPref = function(icons) {\n    return findBestIcon(icons, options.ext);\n  };\n\n  return getPage(pageUrl)\n  .then(function (dom) {\n    return getIconLinks(pageUrl, dom);\n  })\n  .then(downloadIcons)\n  .then(bestWithPref)\n  .then(result => {\n    if (result || isHttps(pageUrl)) {\n      return result;\n    }\n\n    const httpsUrl = makeHttps(pageUrl);\n    return main(httpsUrl, options);\n  });\n}\n\nmodule.exports = main;\n"]}