@sofaws/dapp-core
Version:
A library to hold the main logic for a dapp on the Elrond Network
3 lines (2 loc) • 1.45 kB
JavaScript
import{m as P}from"./chunk-HBP5N4FR.js";P();function h(e,t){if(!e){typeof console!="undefined"&&console.warn(t);try{throw new Error(t)}catch(n){}}}function $(e,t){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[n,r]=o(e.path,e.caseSensitive,e.end),a=t.match(n);if(!a)return null;let s=a[0],g=s.replace(/(.)\/+$/,"$1"),i=a.slice(1);return{params:r.reduce((m,l,c)=>{if(l==="*"){let d=i[c]||"";g=s.slice(0,s.length-d.length).replace(/(.)\/+$/,"$1")}return m[l]=u(i[c]||"",l),m},{}),pathname:s,pathnameBase:g,pattern:e}}function o(e,t=!1,n=!0){h(e==="*"||!e.endsWith("*")||e.endsWith("/*"),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,"/*")}".`);let r=[],a="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^$?{}|()[\]]/g,"\\$&").replace(/:(\w+)/g,(g,i)=>(r.push(i),"([^\\/]+)"));return e.endsWith("*")?(r.push("*"),a+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):a+=n?"\\/*$":"(?:(?=[.~-]|%[0-9A-F]{2})|\\b|\\/|$)",[new RegExp(a,t?void 0:"i"),r]}function u(e,t){try{return decodeURIComponent(e)}catch(n){return h(!1,`The value for the URL param "${t}" will not be decoded because the string "${e}" is a malformed URL segment. This is probably due to a bad percent encoding (${n}).`),e}}export{$ as a};
//# sourceMappingURL=chunk-2JEF2QS7.js.map