mirror of https://github.com/aminya/setup-cpp
2 lines
4.5 KiB
JavaScript
2 lines
4.5 KiB
JavaScript
var e=("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{}).parcelRequire810d;e.register("kCYt6",function(t,n){Object.defineProperty(t.exports,"toFormData",{get:()=>D,set:void 0,enumerable:!0,configurable:!0});var a=e("wabHV"),r=e("33Q0z");let i=0,o={START_BOUNDARY:i++,HEADER_FIELD_START:i++,HEADER_FIELD:i++,HEADER_VALUE_START:i++,HEADER_VALUE:i++,HEADER_VALUE_ALMOST_DONE:i++,HEADERS_ALMOST_DONE:i++,PART_DATA_START:i++,PART_DATA:i++,END:i++},A=1,s={PART_BOUNDARY:A,LAST_BOUNDARY:A*=2},d=e=>32|e,E=()=>{};class l{constructor(e){this.index=0,this.flags=0,this.onHeaderEnd=E,this.onHeaderField=E,this.onHeadersEnd=E,this.onHeaderValue=E,this.onPartBegin=E,this.onPartData=E,this.onPartEnd=E,this.boundaryChars={},e="\r\n--"+e;let t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n),this.boundaryChars[t[n]]=!0;this.boundary=t,this.lookbehind=new Uint8Array(this.boundary.length+8),this.state=o.START_BOUNDARY;}write(e){let t,n,a=0,r=e.length,i=this.index,{lookbehind:A,boundary:E,boundaryChars:l,index:D,state:h,flags:f}=this,T=this.boundary.length,_=T-1,R=e.length,u=e=>{this[e+"Mark"]=a;},c=e=>{delete this[e+"Mark"];},b=(e,t,n,a)=>{(void 0===t||t!==n)&&this[e](a&&a.subarray(t,n));},H=(t,n)=>{let r=t+"Mark";r in this&&(n?(b(t,this[r],a,e),delete this[r]):(b(t,this[r],e.length,e),this[r]=0));};for(a=0;a<r;a++)switch(t=e[a],h){case o.START_BOUNDARY:if(D===E.length-2){if(45===t)f|=s.LAST_BOUNDARY;else if(13!==t)return;D++;break;}if(D-1==E.length-2){if(f&s.LAST_BOUNDARY&&45===t)h=o.END,f=0;else{if(f&s.LAST_BOUNDARY||10!==t)return;D=0,b("onPartBegin"),h=o.HEADER_FIELD_START;}break;}t!==E[D+2]&&(D=-2),t===E[D+2]&&D++;break;case o.HEADER_FIELD_START:h=o.HEADER_FIELD,u("onHeaderField"),D=0;case o.HEADER_FIELD:if(13===t){c("onHeaderField"),h=o.HEADERS_ALMOST_DONE;break;}if(D++,45===t)break;if(58===t){if(1===D)return;H("onHeaderField",!0),h=o.HEADER_VALUE_START;break;}if((n=d(t))<97||n>122)return;break;case o.HEADER_VALUE_START:if(32===t)break;u("onHeaderValue"),h=o.HEADER_VALUE;case o.HEADER_VALUE:13===t&&(H("onHeaderValue",!0),b("onHeaderEnd"),h=o.HEADER_VALUE_ALMOST_DONE);break;case o.HEADER_VALUE_ALMOST_DONE:if(10!==t)return;h=o.HEADER_FIELD_START;break;case o.HEADERS_ALMOST_DONE:if(10!==t)return;b("onHeadersEnd"),h=o.PART_DATA_START;break;case o.PART_DATA_START:h=o.PART_DATA,u("onPartData");case o.PART_DATA:if(i=D,0===D){for(a+=_;a<R&&!(e[a]in l);)a+=T;a-=_,t=e[a];}if(D<E.length)E[D]===t?(0===D&&H("onPartData",!0),D++):D=0;else if(D===E.length)D++,13===t?f|=s.PART_BOUNDARY:45===t?f|=s.LAST_BOUNDARY:D=0;else if(D-1===E.length){if(f&s.PART_BOUNDARY){if(D=0,10===t){f&=~s.PART_BOUNDARY,b("onPartEnd"),b("onPartBegin"),h=o.HEADER_FIELD_START;break;}}else f&s.LAST_BOUNDARY&&45===t?(b("onPartEnd"),h=o.END,f=0):D=0;}if(D>0)A[D-1]=t;else if(i>0){let e=new Uint8Array(A.buffer,A.byteOffset,A.byteLength);b("onPartData",0,i,e),i=0,u("onPartData"),a--;}break;case o.END:break;default:throw Error(`Unexpected state entered: ${h}`);}H("onHeaderField"),H("onHeaderValue"),H("onPartData"),this.index=D,this.state=h,this.flags=f;}end(){if(this.state===o.HEADER_FIELD_START&&0===this.index||this.state===o.PART_DATA&&this.index===this.boundary.length)this.onPartEnd();else if(this.state!==o.END)throw Error("MultipartParser.end(): stream ended unexpectedly");}}async function D(e,t){let n,i,o,A,s,d;if(!/multipart/i.test(t))throw TypeError("Failed to fetch");let E=t.match(/boundary=(?:"([^"]+)"|([^;]+))/i);if(!E)throw TypeError("no or bad content-type header, no multipart boundary");let D=new l(E[1]||E[2]),h=[],f=new r.FormData(),T=e=>{o+=c.decode(e,{stream:!0});},_=e=>{h.push(e);},R=()=>{let e=new a.File(h,d,{type:s});f.append(A,e);},u=()=>{f.append(A,o);},c=new TextDecoder("utf-8");for await(let t of(c.decode(),D.onPartBegin=function(){D.onPartData=T,D.onPartEnd=u,n="",i="",o="",A="",s="",d=null,h.length=0;},D.onHeaderField=function(e){n+=c.decode(e,{stream:!0});},D.onHeaderValue=function(e){i+=c.decode(e,{stream:!0});},D.onHeaderEnd=function(){if(i+=c.decode(),"content-disposition"===(n=n.toLowerCase())){let e=i.match(/\bname=("([^"]*)"|([^()<>@,;:\\"/[\]?={}\s\t]+))/i);e&&(A=e[2]||e[3]||""),(d=function(e){let t=e.match(/\bfilename=("(.*?)"|([^()<>@,;:\\"/[\]?={}\s\t]+))($|;\s)/i);if(!t)return;let n=t[2]||t[3]||"",a=n.slice(n.lastIndexOf("\\")+1);return(a=a.replace(/%22/g,'"')).replace(/&#(\d{4});/g,(e,t)=>String.fromCharCode(t));}(i))&&(D.onPartData=_,D.onPartEnd=R);}else"content-type"===n&&(s=i);i="",n="";},e))D.write(t);return D.end(),f;}});
|
|
//# sourceMappingURL=multipart-parser.dbeb496e.js.map
|