Skip to content

Commit 5c63790

Browse files
committed
"User-Agent"
1 parent 89a3eba commit 5c63790

File tree

5 files changed

+10
-5
lines changed

5 files changed

+10
-5
lines changed

lib/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/index.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
import c from"path";import l from"@hattip/polyfills/node-fetch";function u(n){return n?.startsWith("http://")||n?.startsWith("https://")}const w=new Map,m=function({cache:n=w,onRequest:f,onUseCache:h,fetcher:a,resolveIdFallback:o}={}){return l(),{name:"rollup-plugin-http-resolve",async resolveId(t,r){if(/^https?:\/\//.test(t))return t;if(r&&u(r)){if(t.startsWith("https://"))return t;const{pathname:e,protocol:s,host:i}=new URL(r);if(t.startsWith("/"))return`${s}//${i}${t}`;if(t.startsWith(".")){const p=c.join(c.dirname(e),t);return`${s}//${i}${p}`}}else if(o){const e=o(t,r);if(e)return e}},async load(t){if(t!==null&&u(t)){const r=await n.get(t);if(r)return h?.(t),r;if(f?.(t),a){const e=await a(t);return await n.set(t,e),e}else{const e=await fetch(t);if(!e.ok)throw e.statusText;const s=await e.text();return await n.set(t,s),s}}}}};export{m as httpResolve};
1+
import c from"path";import l from"@hattip/polyfills/node-fetch";function h(s){return s?.startsWith("http://")||s?.startsWith("https://")}const w=new Map,m=function({cache:s=w,onRequest:f,onUseCache:p,fetcher:a,resolveIdFallback:i}={}){return l(),{name:"rollup-plugin-http-resolve",async resolveId(t,r){if(/^https?:\/\//.test(t))return t;if(r&&h(r)){if(t.startsWith("https://"))return t;const{pathname:e,protocol:n,host:o}=new URL(r);if(t.startsWith("/"))return`${n}//${o}${t}`;if(t.startsWith(".")){const u=c.join(c.dirname(e),t);return`${n}//${o}${u}`}}else if(i){const e=i(t,r);if(e)return e}},async load(t){if(t!==null&&h(t)){const r=await s.get(t);if(r)return p?.(t),r;if(f?.(t),a){const e=await a(t);return await s.set(t,e),e}else{const e=await fetch(t,{headers:{"User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36 Edg/108.0.1462.54"}});if(!e.ok)throw e.statusText;const n=await e.text();return await s.set(t,n),n}}}}};export{m as httpResolve};
22
//# sourceMappingURL=index.mjs.map

0 commit comments

Comments
 (0)