1 line
22 KiB
JavaScript
1 line
22 KiB
JavaScript
|
|
module.exports = "\"use strict\";var yt=Object.defineProperty,Le=Object.getOwnPropertyDescriptor,Ae=Object.getOwnPropertyNames,Te=Object.prototype.hasOwnProperty,h=(t,e)=>yt(t,\"name\",{value:e,configurable:!0}),Ue=(t,e)=>{for(var s in e)yt(t,s,{get:e[s],enumerable:!0})},Me=(t,e,s,r)=>{if(e&&typeof e==\"object\"||typeof e==\"function\")for(let c of Ae(e))!Te.call(t,c)&&c!==s&&yt(t,c,{get:()=>e[c],enumerable:!(r=Le(e,c))||r.enumerable});return t},Ie=t=>Me(yt({},\"__esModule\",{value:!0}),t),Ht=(t,e,s)=>{if(!e.has(t))throw TypeError(\"Cannot \"+s)},i=(t,e,s)=>(Ht(t,e,\"read from private field\"),s?s.call(t):e.get(t)),p=(t,e,s)=>{if(e.has(t))throw TypeError(\"Cannot add the same private member more than once\");e instanceof WeakSet?e.add(t):e.set(t,s)},v=(t,e,s,r)=>(Ht(t,e,\"write to private field\"),r?r.call(t,s):e.set(t,s),s),a=(t,e,s)=>(Ht(t,e,\"access private method\"),s),oe={};Ue(oe,{URLPattern:()=>Oe});module.exports=Ie(oe);var xt,ut=(xt=class{type=3;name=\"\";prefix=\"\";value=\"\";suffix=\"\";modifier=3;constructor(t,e,s,r,c,f){this.type=t,this.name=e,this.prefix=s,this.value=r,this.suffix=c,this.modifier=f}hasCustomName(){return this.name!==\"\"&&typeof this.name!=\"number\"}},h(xt,\"R\"),xt),De=/[$_\\p{ID_Start}]/u,Ne=/[$_\\u200C\\u200D\\p{ID_Continue}]/u,Dt=\".*\";function le(t,e){return(e?/^[\\x00-\\xFF]*$/:/^[\\x00-\\x7F]*$/).test(t)}h(le,\"Re\");function Ft(t,e=!1){let s=[],r=0;for(;r<t.length;){let c=t[r],f=h(function(l){if(!e)throw new TypeError(l);s.push({type:\"INVALID_CHAR\",index:r,value:t[r++]})},\"c\");if(c===\"*\"){s.push({type:\"ASTERISK\",index:r,value:t[r++]});continue}if(c===\"+\"||c===\"?\"){s.push({type:\"OTHER_MODIFIER\",index:r,value:t[r++]});continue}if(c===\"\\\\\"){s.push({type:\"ESCAPED_CHAR\",index:r++,value:t[r++]});continue}if(c===\"{\"){s.push({type:\"OPEN\",index:r,value:t[r++]});continue}if(c===\"}\"){s.push({type:\"CLOSE\",index:r,value:t[r++]});continue}if(c===\":\"){let l=\"\",n=r+1;for(;n<t.length;){let u=t.substr(n,1);if(n===r+1&&De.test(u)||n!==r+1&&Ne.test(u)){l+=t[n++];continue}break}if(!l){f(`Missing parameter name at ${r}`);continue}s.push({type:\"NAME\",index:r,value:l}),r=n;continue}if(c===\"(\"){let l=1,n=\"\",u=r+1,o=!1;if(t[u]===\"?\"){f(`Pattern cannot start with \"?\" at ${u}`);continue}for(;u<t.length;){if(!le(t[u],!1)){f(`Invalid character '${t[u]}' at ${u}.`),o=!0;break}if(t[u]===\"\\\\\"){n+=t[u++]+t[u++];continue}if(t[u]===\")\"){if(l--,l===0){u++;break}}else if(t[u]===\"(\"&&(l++,t[u+1]!==\"?\")){f(`Capturing groups are not allowed at ${u}`),o=!0;break}n+=t[u++]}if(o)continue;if(l){f(`Unbalanced pattern at ${r}`);continue}if(!n){f(`Missing pattern at ${r}`);continue}s.push({type:\"REGEX\",index:r,value:n}),r=u;continue}s.push({type:\"CHAR\",index:r,value:t[r++]})}return s.push({type:\"END\",index:r,value:\"\"}),s}h(Ft,\"v\");function Gt(t,e={}){let s=Ft(t);e.delimiter??=\"/#?\",e.prefixes??=\"./\";let r=`[^${R(e.delimiter)}]+?`,c=[],f=0,l=0,n=\"\",u=new Set,o=h(w=>{if(l<s.length&&s[l].type===w)return s[l++].value},\"a\"),x=h(()=>o(\"OTHER_MODIFIER\")??o(\"ASTERISK\"),\"f\"),L=h(w=>{let b=o(w);if(b!==void 0)return b;let{type:$,index:J}=s[l];throw new TypeError(`Unexpected ${$} at ${J}, expected ${w}`)},\"d\"),z=h(()=>{let w=\"\",b;for(;b=o(\"CHAR\")??o(\"ESCAPED_CHAR\");)w+=b;return w},\"T\"),Pe=h(w=>w,\"Se\"),ft=e.encodePart||Pe,pt=\"\",bt=h(w=>{pt+=w},\"U\"),kt=h(()=>{pt.length&&(c.push(new ut(3,\"\",\"\",ft(pt),\"\",3)),pt=\"\")},\"$\"),Bt=h((w,b,$,J,I)=>{let O=3;switch(I){case\"?\":O=1;break;case\"*\":O=0;break;case\"+\":O=2;break}if(!b&&!$&&O===3){bt(w);return}if(kt(),!b&&!$){if(!w)return;c.push(new ut(3,\"\",\"\",ft(w),\"\",O));return}let S;$?$===\"*\"?S=Dt:S=$:S=r;let et=2;S===r?(et=1,S=\"\"):S===Dt&&(et=0,S=\"\");let D;if(b?D=b:$&&(D=f++),u.has(D))throw new TypeError(`Duplicate name '${D}'.`);u.add(D),c.push(new ut(et,D,ft(w),S,ft(J),O))},\"V\");for(;l<s.length;){let w=o(\"CHAR\"),b=o(\"NAME\"),$=o(\"REGEX\");if(!b&&!$&&($=o(\"ASTERISK\")),b||$){let I=w??\"\";e.prefixes.indexOf(I)===-1&&(bt(I),I=\"\"),kt();let O=x();Bt(I,b,$,\"\",O);continue}let J=w??o(
|