UNPKG

2.15 kBJavaScriptView Raw
1
2!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="cd27a926-bc6c-55ea-8245-94760e9ef090")}catch(e){}}();
3(self.webpackChunkaltair=self.webpackChunkaltair||[]).push([[994],{58994:A=>{const e_STATES_HEADER="header-state",e_STATES_CUSTOM_METHOD="custom-method-state",e_STATES_DATA="data-state",e_STATES_USER="user-state",n=[{regex:/^\bcurl\b/,name:"curl"},{regex:/^(-H|--header)/,name:e_STATES_HEADER},{regex:/^-X/,name:e_STATES_CUSTOM_METHOD},{regex:/^(-u|--user)/,name:e_STATES_USER},{regex:/^(-d|--data)/,name:e_STATES_DATA},{regex:/^--compressed/,name:"compressed"},{regex:/^(-i|--include)/,name:"include-headers"},{regex:/^(-s|--silent)/,name:"run-silent"},{regex:/^(-G|--get)/,name:"use-get"},{regex:/^'[^']*'/,name:"string"},{regex:/^"[^"]*"/,name:"string"},{regex:/^[^\n\r\s]*/,name:"string"},{regex:/^.*/,name:"others"}],t=T=>T.trim().replace(/^('|")\s*/,"").replace(/\s*('|")$/,"");A.exports={parseCurl:T=>{let S=T.trim();const c=[],E={url:"",method:"GET",headers:{},auth:{}};for(;S;)n.some(a=>{if(a.regex.test(S))return c.push({name:a.name,value:S.match(a.regex)}),S=S.replace(a.regex,"").trim(),!0});if(c.length){if("curl"!==c.shift().name)throw new Error("Not a curl command.");let a="";c.forEach(r=>{if(a){switch(a){case e_STATES_HEADER:{const s=t(r.value[0]).split(/\s*:\s*/);E.headers[s[0]]=s[1];break}case e_STATES_DATA:E.data=t(r.value[0]).trim();break;case e_STATES_CUSTOM_METHOD:E.method=t(r.value[0]).trim()}a=""}else switch(r.name){case e_STATES_HEADER:a=e_STATES_HEADER;break;case e_STATES_DATA:a=e_STATES_DATA;break;case e_STATES_CUSTOM_METHOD:a=e_STATES_CUSTOM_METHOD;break;case e_STATES_USER:a=e_STATES_USER;break;case"string":{const s=t(r.value[0]);(T=>/((([A-Za-z]{3,9}:(?:\/\/)?)(?:[\-;:&=\+\$,\w]+@)?[A-Za-z0-9\.\-]+|(?:www\.|[\-;:&=\+\$,\w]+@)[A-Za-z0-9\.\-]+)((?:\/[\+~%\/\.\w\-_]*)?\??(?:[\-\+=&;%@\.\w_]*)#?(?:[\.\!\/\\\w]*))?)/.test(T))(s)&&(E.url=s);break}}})}return E}}}}]);
4//# sourceMappingURL=994.js.map
5//# debugId=cd27a926-bc6c-55ea-8245-94760e9ef090