Skip to content

Instantly share code, notes, and snippets.

@kgamecarter
Created April 16, 2022 16:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kgamecarter/b64731e71aeecaa373aa31f81f8a1a43 to your computer and use it in GitHub Desktop.
Save kgamecarter/b64731e71aeecaa373aa31f81f8a1a43 to your computer and use it in GitHub Desktop.
fix react-router path start with @ symbol
diff --git a/node_modules/react-router/index.js b/node_modules/react-router/index.js
index 7f42297..a0dffec 100644
--- a/node_modules/react-router/index.js
+++ b/node_modules/react-router/index.js
@@ -307,7 +307,7 @@ function compilePath(path, caseSensitive, end) {
// Additionally, allow paths starting with `.`, `-`, `~`, and url-encoded entities,
// but do not consume the character in the matched path so they can match against
// nested paths.
- "(?:(?=[.~-]|%[0-9A-F]{2})|\\b|\\/|$)";
+ "(?:(?=[@.~-]|%[0-9A-F]{2})|\\b|\\/|$)";
}
let matcher = new RegExp(regexpSource, caseSensitive ? undefined : "i");
diff --git a/node_modules/react-router/react-router.development.js b/node_modules/react-router/react-router.development.js
index aded811..83b3bdf 100644
--- a/node_modules/react-router/react-router.development.js
+++ b/node_modules/react-router/react-router.development.js
@@ -279,7 +279,7 @@ function compilePath(path, caseSensitive = false, end = true) {
// Additionally, allow paths starting with `.`, `-`, `~`, and url-encoded entities,
// but do not consume the character in the matched path so they can match against
// nested paths.
- "(?:(?=[.~-]|%[0-9A-F]{2})|\\b|\\/|$)";
+ "(?:(?=[@.~-]|%[0-9A-F]{2})|\\b|\\/|$)";
}
let matcher = new RegExp(regexpSource, caseSensitive ? undefined : "i");
diff --git a/node_modules/react-router/react-router.production.min.js b/node_modules/react-router/react-router.production.min.js
index c8d9212..cfa74ff 100644
--- a/node_modules/react-router/react-router.production.min.js
+++ b/node_modules/react-router/react-router.production.min.js
@@ -8,5 +8,5 @@
*
* @license MIT
*/
-import{parsePath as e,createMemoryHistory as t,Action as n}from"history";export{Action as NavigationType,createPath,parsePath}from"history";import{createContext as a,useContext as r,useMemo as l,useRef as i,useEffect as s,useCallback as o,createElement as h,useState as c,useLayoutEffect as u,Children as p,isValidElement as m,Fragment as f}from"react";const g=a(null),d=a(null),v=a({outlet:null,matches:[]});function y(e,t){if(!e)throw new Error(t)}function x(e,t={}){return e.replace(/:(\w+)/g,((e,n)=>(null==t[n]&&y(!1),t[n]))).replace(/\/*\*$/,(e=>null==t["*"]?"":t["*"].replace(/^\/*/,"/")))}function S(t,n,a="/"){let r=O(("string"==typeof n?e(n):n).pathname||"/",a);if(null==r)return null;let l=$(t);!function(e){e.sort(((e,t)=>e.score!==t.score?t.score-e.score:function(e,t){return e.length===t.length&&e.slice(0,-1).every(((e,n)=>e===t[n]))?e[e.length-1]-t[t.length-1]:0}(e.routesMeta.map((e=>e.childrenIndex)),t.routesMeta.map((e=>e.childrenIndex)))))}(l);let i=null;for(let e=0;null==i&&e<l.length;++e)i=B(l[e],r);return i}function $(e,t=[],n=[],a=""){return e.forEach(((e,r)=>{let l={relativePath:e.path||"",caseSensitive:!0===e.caseSensitive,childrenIndex:r,route:e};l.relativePath.startsWith("/")&&(l.relativePath.startsWith(a)||y(!1),l.relativePath=l.relativePath.slice(a.length));let i=j([a,l.relativePath]),s=n.concat(l);e.children&&e.children.length>0&&(!0===e.index&&y(!1),$(e.children,t,s,i)),(null!=e.path||e.index)&&t.push({path:i,score:b(i,e.index),routesMeta:s})})),t}const P=/^:\w+$/,W=e=>"*"===e;function b(e,t){let n=e.split("/"),a=n.length;return n.some(W)&&(a+=-2),t&&(a+=2),n.filter((e=>!W(e))).reduce(((e,t)=>e+(P.test(t)?3:""===t?1:10)),a)}function B(e,t){let{routesMeta:n}=e,a={},r="/",l=[];for(let i=0;i<n.length;++i){let e=n[i],s=i===n.length-1,o="/"===r?t:t.slice(r.length)||"/",h=E({path:e.relativePath,caseSensitive:e.caseSensitive,end:s},o);if(!h)return null;Object.assign(a,h.params);let c=e.route;l.push({params:a,pathname:j([r,h.pathname]),pathnameBase:A(j([r,h.pathnameBase])),route:c}),"/"!==h.pathnameBase&&(r=j([r,h.pathnameBase]))}return l}function E(e,t){"string"==typeof e&&(e={path:e,caseSensitive:!1,end:!0});let[n,a]=function(e,t=!1,n=!0){let a=[],r="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^$?{}|()[\]]/g,"\\$&").replace(/:(\w+)/g,((e,t)=>(a.push(t),"([^\\/]+)")));e.endsWith("*")?(a.push("*"),r+="*"===e||"/*"===e?"(.*)$":"(?:\\/(.+)|\\/*)$"):r+=n?"\\/*$":"(?:(?=[.~-]|%[0-9A-F]{2})|\\b|\\/|$)";return[new RegExp(r,t?void 0:"i"),a]}(e.path,e.caseSensitive,e.end),r=t.match(n);if(!r)return null;let l=r[0],i=l.replace(/(.)\/+$/,"$1"),s=r.slice(1);return{params:a.reduce(((e,t,n)=>{if("*"===t){let e=s[n]||"";i=l.slice(0,l.length-e.length).replace(/(.)\/+$/,"$1")}return e[t]=function(e,t){try{return decodeURIComponent(e)}catch(n){return e}}(s[n]||""),e}),{}),pathname:l,pathnameBase:i,pattern:e}}function N(t,n="/"){let{pathname:a,search:r="",hash:l=""}="string"==typeof t?e(t):t,i=a?a.startsWith("/")?a:function(e,t){let n=t.replace(/\/+$/,"").split("/");return e.split("/").forEach((e=>{".."===e?n.length>1&&n.pop():"."!==e&&n.push(e)})),n.length>1?n.join("/"):"/"}(a,n):n;return{pathname:i,search:C(r),hash:I(l)}}function w(t,n,a){let r,l="string"==typeof t?e(t):t,i=""===t||""===l.pathname?"/":l.pathname;if(null==i)r=a;else{let e=n.length-1;if(i.startsWith("..")){let t=i.split("/");for(;".."===t[0];)t.shift(),e-=1;l.pathname=t.join("/")}r=e>=0?n[e]:"/"}let s=N(l,r);return i&&"/"!==i&&i.endsWith("/")&&!s.pathname.endsWith("/")&&(s.pathname+="/"),s}function O(e,t){if("/"===t)return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=e.charAt(t.length);return n&&"/"!==n?null:e.slice(t.length)||"/"}const j=e=>e.join("/").replace(/\/\/+/g,"/"),A=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),C=e=>e&&"?"!==e?e.startsWith("?")?e:"?"+e:"",I=e=>e&&"#"!==e?e.startsWith("#")?e:"#"+e:"";function T(t){F()||y(!1);let{basename:n,navigator:a}=r(g),{hash:l,pathname:i,search:s}=q(t),o=i;if("/"!==n){let a=function(t){return""===t||""===t.pathname?"/":"string"==typeof t?e(t).pathname:t.pathname}(t),r=null!=a&&a.endsWith("/");o="/"===i?n+(r?"/":""):j([n,i])}return a.createHref({pathname:o,search:s,hash:l})}function F(){return null!=r(d)}function J(){return F()||y(!1),r(d).location}function M(){return r(d).navigationType}function R(e){F()||y(!1);let{pathname:t}=J();return l((()=>E(e,t)),[t,e])}function U(){F()||y(!1);let{basename:e,navigator:t}=r(g),{matches:n}=r(v),{pathname:a}=J(),l=JSON.stringify(n.map((e=>e.pathnameBase))),h=i(!1);return s((()=>{h.current=!0})),o(((n,r={})=>{if(!h.current)return;if("number"==typeof n)return void t.go(n);let i=w(n,JSON.parse(l),a);"/"!==e&&(i.pathname=j([e,i.pathname])),(r.replace?t.replace:t.push)(i,r.state)}),[e,t,l,a])}const L=a(null);function _(){return r(L)}function k(e){let t=r(v).outlet;return t?h(L.Provider,{value:e},t):t}function H(){let{matches:e}=r(v),t=e[e.length-1];return t?t.params:{}}function q(e){let{matches:t}=r(v),{pathname:n}=J(),a=JSON.stringify(t.map((e=>e.pathnameBase)));return l((()=>w(e,JSON.parse(a),n)),[e,a,n])}function z(t,n){F()||y(!1);let a,{matches:l}=r(v),i=l[l.length-1],s=i?i.params:{},o=(i&&i.pathname,i?i.pathnameBase:"/"),h=(i&&i.route,J());if(n){let t="string"==typeof n?e(n):n;"/"===o||t.pathname?.startsWith(o)||y(!1),a=t}else a=h;let c=a.pathname||"/",u=S(t,{pathname:"/"===o?c:c.slice(o.length)||"/"});return D(u&&u.map((e=>Object.assign({},e,{params:Object.assign({},s,e.params),pathname:j([o,e.pathname]),pathnameBase:"/"===e.pathnameBase?o:j([o,e.pathnameBase])}))),l)}function D(e,t=[]){return null==e?null:e.reduceRight(((n,a,r)=>h(v.Provider,{children:void 0!==a.route.element?a.route.element:n,value:{outlet:n,matches:t.concat(e.slice(0,r+1))}})),null)}function G({basename:e,children:n,initialEntries:a,initialIndex:r}){let l=i();null==l.current&&(l.current=t({initialEntries:a,initialIndex:r}));let s=l.current,[o,p]=c({action:s.action,location:s.location});return u((()=>s.listen(p)),[s]),h(X,{basename:e,children:n,location:o.location,navigationType:o.action,navigator:s})}function K({to:e,replace:t,state:n}){F()||y(!1);let a=U();return s((()=>{a(e,{replace:t,state:n})})),null}function Q(e){return k(e.context)}function V(e){y(!1)}function X({basename:t="/",children:a=null,location:r,navigationType:i=n.Pop,navigator:s,static:o=!1}){F()&&y(!1);let c=A(t),u=l((()=>({basename:c,navigator:s,static:o})),[c,s,o]);"string"==typeof r&&(r=e(r));let{pathname:p="/",search:m="",hash:f="",state:v=null,key:x="default"}=r,S=l((()=>{let e=O(p,c);return null==e?null:{pathname:e,search:m,hash:f,state:v,key:x}}),[c,p,m,f,v,x]);return null==S?null:h(g.Provider,{value:u},h(d.Provider,{children:a,value:{location:S,navigationType:i}}))}function Y({children:e,location:t}){return z(Z(e),t)}function Z(e){let t=[];return p.forEach(e,(e=>{if(!m(e))return;if(e.type===f)return void t.push.apply(t,Z(e.props.children));e.type!==V&&y(!1);let n={caseSensitive:e.props.caseSensitive,element:e.props.element,index:e.props.index,path:e.props.path};e.props.children&&(n.children=Z(e.props.children)),t.push(n)})),t}function ee(e){return D(e)}export{G as MemoryRouter,K as Navigate,Q as Outlet,V as Route,X as Router,Y as Routes,d as UNSAFE_LocationContext,g as UNSAFE_NavigationContext,v as UNSAFE_RouteContext,Z as createRoutesFromChildren,x as generatePath,E as matchPath,S as matchRoutes,ee as renderMatches,N as resolvePath,T as useHref,F as useInRouterContext,J as useLocation,R as useMatch,U as useNavigate,M as useNavigationType,k as useOutlet,_ as useOutletContext,H as useParams,q as useResolvedPath,z as useRoutes};
+import{parsePath as e,createMemoryHistory as t,Action as n}from"history";export{Action as NavigationType,createPath,parsePath}from"history";import{createContext as a,useContext as r,useMemo as l,useRef as i,useEffect as s,useCallback as o,createElement as h,useState as c,useLayoutEffect as u,Children as p,isValidElement as m,Fragment as f}from"react";const g=a(null),d=a(null),v=a({outlet:null,matches:[]});function y(e,t){if(!e)throw new Error(t)}function x(e,t={}){return e.replace(/:(\w+)/g,((e,n)=>(null==t[n]&&y(!1),t[n]))).replace(/\/*\*$/,(e=>null==t["*"]?"":t["*"].replace(/^\/*/,"/")))}function S(t,n,a="/"){let r=O(("string"==typeof n?e(n):n).pathname||"/",a);if(null==r)return null;let l=$(t);!function(e){e.sort(((e,t)=>e.score!==t.score?t.score-e.score:function(e,t){return e.length===t.length&&e.slice(0,-1).every(((e,n)=>e===t[n]))?e[e.length-1]-t[t.length-1]:0}(e.routesMeta.map((e=>e.childrenIndex)),t.routesMeta.map((e=>e.childrenIndex)))))}(l);let i=null;for(let e=0;null==i&&e<l.length;++e)i=B(l[e],r);return i}function $(e,t=[],n=[],a=""){return e.forEach(((e,r)=>{let l={relativePath:e.path||"",caseSensitive:!0===e.caseSensitive,childrenIndex:r,route:e};l.relativePath.startsWith("/")&&(l.relativePath.startsWith(a)||y(!1),l.relativePath=l.relativePath.slice(a.length));let i=j([a,l.relativePath]),s=n.concat(l);e.children&&e.children.length>0&&(!0===e.index&&y(!1),$(e.children,t,s,i)),(null!=e.path||e.index)&&t.push({path:i,score:b(i,e.index),routesMeta:s})})),t}const P=/^:\w+$/,W=e=>"*"===e;function b(e,t){let n=e.split("/"),a=n.length;return n.some(W)&&(a+=-2),t&&(a+=2),n.filter((e=>!W(e))).reduce(((e,t)=>e+(P.test(t)?3:""===t?1:10)),a)}function B(e,t){let{routesMeta:n}=e,a={},r="/",l=[];for(let i=0;i<n.length;++i){let e=n[i],s=i===n.length-1,o="/"===r?t:t.slice(r.length)||"/",h=E({path:e.relativePath,caseSensitive:e.caseSensitive,end:s},o);if(!h)return null;Object.assign(a,h.params);let c=e.route;l.push({params:a,pathname:j([r,h.pathname]),pathnameBase:A(j([r,h.pathnameBase])),route:c}),"/"!==h.pathnameBase&&(r=j([r,h.pathnameBase]))}return l}function E(e,t){"string"==typeof e&&(e={path:e,caseSensitive:!1,end:!0});let[n,a]=function(e,t=!1,n=!0){let a=[],r="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^$?{}|()[\]]/g,"\\$&").replace(/:(\w+)/g,((e,t)=>(a.push(t),"([^\\/]+)")));e.endsWith("*")?(a.push("*"),r+="*"===e||"/*"===e?"(.*)$":"(?:\\/(.+)|\\/*)$"):r+=n?"\\/*$":"(?:(?=[@.~-]|%[0-9A-F]{2})|\\b|\\/|$)";return[new RegExp(r,t?void 0:"i"),a]}(e.path,e.caseSensitive,e.end),r=t.match(n);if(!r)return null;let l=r[0],i=l.replace(/(.)\/+$/,"$1"),s=r.slice(1);return{params:a.reduce(((e,t,n)=>{if("*"===t){let e=s[n]||"";i=l.slice(0,l.length-e.length).replace(/(.)\/+$/,"$1")}return e[t]=function(e,t){try{return decodeURIComponent(e)}catch(n){return e}}(s[n]||""),e}),{}),pathname:l,pathnameBase:i,pattern:e}}function N(t,n="/"){let{pathname:a,search:r="",hash:l=""}="string"==typeof t?e(t):t,i=a?a.startsWith("/")?a:function(e,t){let n=t.replace(/\/+$/,"").split("/");return e.split("/").forEach((e=>{".."===e?n.length>1&&n.pop():"."!==e&&n.push(e)})),n.length>1?n.join("/"):"/"}(a,n):n;return{pathname:i,search:C(r),hash:I(l)}}function w(t,n,a){let r,l="string"==typeof t?e(t):t,i=""===t||""===l.pathname?"/":l.pathname;if(null==i)r=a;else{let e=n.length-1;if(i.startsWith("..")){let t=i.split("/");for(;".."===t[0];)t.shift(),e-=1;l.pathname=t.join("/")}r=e>=0?n[e]:"/"}let s=N(l,r);return i&&"/"!==i&&i.endsWith("/")&&!s.pathname.endsWith("/")&&(s.pathname+="/"),s}function O(e,t){if("/"===t)return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=e.charAt(t.length);return n&&"/"!==n?null:e.slice(t.length)||"/"}const j=e=>e.join("/").replace(/\/\/+/g,"/"),A=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),C=e=>e&&"?"!==e?e.startsWith("?")?e:"?"+e:"",I=e=>e&&"#"!==e?e.startsWith("#")?e:"#"+e:"";function T(t){F()||y(!1);let{basename:n,navigator:a}=r(g),{hash:l,pathname:i,search:s}=q(t),o=i;if("/"!==n){let a=function(t){return""===t||""===t.pathname?"/":"string"==typeof t?e(t).pathname:t.pathname}(t),r=null!=a&&a.endsWith("/");o="/"===i?n+(r?"/":""):j([n,i])}return a.createHref({pathname:o,search:s,hash:l})}function F(){return null!=r(d)}function J(){return F()||y(!1),r(d).location}function M(){return r(d).navigationType}function R(e){F()||y(!1);let{pathname:t}=J();return l((()=>E(e,t)),[t,e])}function U(){F()||y(!1);let{basename:e,navigator:t}=r(g),{matches:n}=r(v),{pathname:a}=J(),l=JSON.stringify(n.map((e=>e.pathnameBase))),h=i(!1);return s((()=>{h.current=!0})),o(((n,r={})=>{if(!h.current)return;if("number"==typeof n)return void t.go(n);let i=w(n,JSON.parse(l),a);"/"!==e&&(i.pathname=j([e,i.pathname])),(r.replace?t.replace:t.push)(i,r.state)}),[e,t,l,a])}const L=a(null);function _(){return r(L)}function k(e){let t=r(v).outlet;return t?h(L.Provider,{value:e},t):t}function H(){let{matches:e}=r(v),t=e[e.length-1];return t?t.params:{}}function q(e){let{matches:t}=r(v),{pathname:n}=J(),a=JSON.stringify(t.map((e=>e.pathnameBase)));return l((()=>w(e,JSON.parse(a),n)),[e,a,n])}function z(t,n){F()||y(!1);let a,{matches:l}=r(v),i=l[l.length-1],s=i?i.params:{},o=(i&&i.pathname,i?i.pathnameBase:"/"),h=(i&&i.route,J());if(n){let t="string"==typeof n?e(n):n;"/"===o||t.pathname?.startsWith(o)||y(!1),a=t}else a=h;let c=a.pathname||"/",u=S(t,{pathname:"/"===o?c:c.slice(o.length)||"/"});return D(u&&u.map((e=>Object.assign({},e,{params:Object.assign({},s,e.params),pathname:j([o,e.pathname]),pathnameBase:"/"===e.pathnameBase?o:j([o,e.pathnameBase])}))),l)}function D(e,t=[]){return null==e?null:e.reduceRight(((n,a,r)=>h(v.Provider,{children:void 0!==a.route.element?a.route.element:n,value:{outlet:n,matches:t.concat(e.slice(0,r+1))}})),null)}function G({basename:e,children:n,initialEntries:a,initialIndex:r}){let l=i();null==l.current&&(l.current=t({initialEntries:a,initialIndex:r}));let s=l.current,[o,p]=c({action:s.action,location:s.location});return u((()=>s.listen(p)),[s]),h(X,{basename:e,children:n,location:o.location,navigationType:o.action,navigator:s})}function K({to:e,replace:t,state:n}){F()||y(!1);let a=U();return s((()=>{a(e,{replace:t,state:n})})),null}function Q(e){return k(e.context)}function V(e){y(!1)}function X({basename:t="/",children:a=null,location:r,navigationType:i=n.Pop,navigator:s,static:o=!1}){F()&&y(!1);let c=A(t),u=l((()=>({basename:c,navigator:s,static:o})),[c,s,o]);"string"==typeof r&&(r=e(r));let{pathname:p="/",search:m="",hash:f="",state:v=null,key:x="default"}=r,S=l((()=>{let e=O(p,c);return null==e?null:{pathname:e,search:m,hash:f,state:v,key:x}}),[c,p,m,f,v,x]);return null==S?null:h(g.Provider,{value:u},h(d.Provider,{children:a,value:{location:S,navigationType:i}}))}function Y({children:e,location:t}){return z(Z(e),t)}function Z(e){let t=[];return p.forEach(e,(e=>{if(!m(e))return;if(e.type===f)return void t.push.apply(t,Z(e.props.children));e.type!==V&&y(!1);let n={caseSensitive:e.props.caseSensitive,element:e.props.element,index:e.props.index,path:e.props.path};e.props.children&&(n.children=Z(e.props.children)),t.push(n)})),t}function ee(e){return D(e)}export{G as MemoryRouter,K as Navigate,Q as Outlet,V as Route,X as Router,Y as Routes,d as UNSAFE_LocationContext,g as UNSAFE_NavigationContext,v as UNSAFE_RouteContext,Z as createRoutesFromChildren,x as generatePath,E as matchPath,S as matchRoutes,ee as renderMatches,N as resolvePath,T as useHref,F as useInRouterContext,J as useLocation,R as useMatch,U as useNavigate,M as useNavigationType,k as useOutlet,_ as useOutletContext,H as useParams,q as useResolvedPath,z as useRoutes};
//# sourceMappingURL=react-router.production.min.js.map
diff --git a/node_modules/react-router/umd/react-router.development.js b/node_modules/react-router/umd/react-router.development.js
index e3b65ee..68d027c 100644
--- a/node_modules/react-router/umd/react-router.development.js
+++ b/node_modules/react-router/umd/react-router.development.js
@@ -309,7 +309,7 @@
// Additionally, allow paths starting with `.`, `-`, `~`, and url-encoded entities,
// but do not consume the character in the matched path so they can match against
// nested paths.
- "(?:(?=[.~-]|%[0-9A-F]{2})|\\b|\\/|$)";
+ "(?:(?=[@.~-]|%[0-9A-F]{2})|\\b|\\/|$)";
}
let matcher = new RegExp(regexpSource, caseSensitive ? undefined : "i");
diff --git a/node_modules/react-router/umd/react-router.production.min.js b/node_modules/react-router/umd/react-router.production.min.js
index 9ec4411..0cfc35f 100644
--- a/node_modules/react-router/umd/react-router.production.min.js
+++ b/node_modules/react-router/umd/react-router.production.min.js
@@ -8,5 +8,5 @@
*
* @license MIT
*/
-!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("history"),require("react")):"function"==typeof define&&define.amd?define(["exports","history","react"],t):t((e=e||self).ReactRouter={},e.HistoryLibrary,e.React)}(this,(function(e,t,n){"use strict";const a=n.createContext(null),r=n.createContext(null),i=n.createContext({outlet:null,matches:[]});function l(e,t){if(!e)throw new Error(t)}function o(e,n,a){void 0===a&&(a="/");let r=g(("string"==typeof n?t.parsePath(n):n).pathname||"/",a);if(null==r)return null;let i=s(e);!function(e){e.sort(((e,t)=>e.score!==t.score?t.score-e.score:function(e,t){return e.length===t.length&&e.slice(0,-1).every(((e,n)=>e===t[n]))?e[e.length-1]-t[t.length-1]:0}(e.routesMeta.map((e=>e.childrenIndex)),t.routesMeta.map((e=>e.childrenIndex)))))}(i);let l=null;for(let e=0;null==l&&e<i.length;++e)l=p(i[e],r);return l}function s(e,t,n,a){return void 0===t&&(t=[]),void 0===n&&(n=[]),void 0===a&&(a=""),e.forEach(((e,r)=>{let i={relativePath:e.path||"",caseSensitive:!0===e.caseSensitive,childrenIndex:r,route:e};i.relativePath.startsWith("/")&&(i.relativePath.startsWith(a)||l(!1),i.relativePath=i.relativePath.slice(a.length));let o=v([a,i.relativePath]),u=n.concat(i);e.children&&e.children.length>0&&(!0===e.index&&l(!1),s(e.children,t,u,o)),(null!=e.path||e.index)&&t.push({path:o,score:h(o,e.index),routesMeta:u})})),t}const u=/^:\w+$/,c=e=>"*"===e;function h(e,t){let n=e.split("/"),a=n.length;return n.some(c)&&(a+=-2),t&&(a+=2),n.filter((e=>!c(e))).reduce(((e,t)=>e+(u.test(t)?3:""===t?1:10)),a)}function p(e,t){let{routesMeta:n}=e,a={},r="/",i=[];for(let e=0;e<n.length;++e){let l=n[e],o=e===n.length-1,s="/"===r?t:t.slice(r.length)||"/",u=f({path:l.relativePath,caseSensitive:l.caseSensitive,end:o},s);if(!u)return null;Object.assign(a,u.params);let c=l.route;i.push({params:a,pathname:v([r,u.pathname]),pathnameBase:y(v([r,u.pathnameBase])),route:c}),"/"!==u.pathnameBase&&(r=v([r,u.pathnameBase]))}return i}function f(e,t){"string"==typeof e&&(e={path:e,caseSensitive:!1,end:!0});let[n,a]=function(e,t,n){void 0===t&&(t=!1);void 0===n&&(n=!0);let a=[],r="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^$?{}|()[\]]/g,"\\$&").replace(/:(\w+)/g,((e,t)=>(a.push(t),"([^\\/]+)")));e.endsWith("*")?(a.push("*"),r+="*"===e||"/*"===e?"(.*)$":"(?:\\/(.+)|\\/*)$"):r+=n?"\\/*$":"(?:(?=[.~-]|%[0-9A-F]{2})|\\b|\\/|$)";return[new RegExp(r,t?void 0:"i"),a]}(e.path,e.caseSensitive,e.end),r=t.match(n);if(!r)return null;let i=r[0],l=i.replace(/(.)\/+$/,"$1"),o=r.slice(1);return{params:a.reduce(((e,t,n)=>{if("*"===t){let e=o[n]||"";l=i.slice(0,i.length-e.length).replace(/(.)\/+$/,"$1")}return e[t]=function(e,t){try{return decodeURIComponent(e)}catch(t){return e}}(o[n]||""),e}),{}),pathname:i,pathnameBase:l,pattern:e}}function m(e,n){void 0===n&&(n="/");let{pathname:a,search:r="",hash:i=""}="string"==typeof e?t.parsePath(e):e,l=a?a.startsWith("/")?a:function(e,t){let n=t.replace(/\/+$/,"").split("/");return e.split("/").forEach((e=>{".."===e?n.length>1&&n.pop():"."!==e&&n.push(e)})),n.length>1?n.join("/"):"/"}(a,n):n;return{pathname:l,search:x(r),hash:P(i)}}function d(e,n,a){let r,i="string"==typeof e?t.parsePath(e):e,l=""===e||""===i.pathname?"/":i.pathname;if(null==l)r=a;else{let e=n.length-1;if(l.startsWith("..")){let t=l.split("/");for(;".."===t[0];)t.shift(),e-=1;i.pathname=t.join("/")}r=e>=0?n[e]:"/"}let o=m(i,r);return l&&"/"!==l&&l.endsWith("/")&&!o.pathname.endsWith("/")&&(o.pathname+="/"),o}function g(e,t){if("/"===t)return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=e.charAt(t.length);return n&&"/"!==n?null:e.slice(t.length)||"/"}const v=e=>e.join("/").replace(/\/\/+/g,"/"),y=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),x=e=>e&&"?"!==e?e.startsWith("?")?e:"?"+e:"",P=e=>e&&"#"!==e?e.startsWith("#")?e:"#"+e:"";function C(){return null!=n.useContext(r)}function b(){return C()||l(!1),n.useContext(r).location}function E(){C()||l(!1);let{basename:e,navigator:t}=n.useContext(a),{matches:r}=n.useContext(i),{pathname:o}=b(),s=JSON.stringify(r.map((e=>e.pathnameBase))),u=n.useRef(!1);return n.useEffect((()=>{u.current=!0})),n.useCallback((function(n,a){if(void 0===a&&(a={}),!u.current)return;if("number"==typeof n)return void t.go(n);let r=d(n,JSON.parse(s),o);"/"!==e&&(r.pathname=v([e,r.pathname])),(a.replace?t.replace:t.push)(r,a.state)}),[e,t,s,o])}const R=n.createContext(null);function S(e){let t=n.useContext(i).outlet;return t?n.createElement(R.Provider,{value:e},t):t}function $(e){let{matches:t}=n.useContext(i),{pathname:a}=b(),r=JSON.stringify(t.map((e=>e.pathnameBase)));return n.useMemo((()=>d(e,JSON.parse(r),a)),[e,r,a])}function O(e,a){C()||l(!1);let r,{matches:s}=n.useContext(i),u=s[s.length-1],c=u?u.params:{},h=(u&&u.pathname,u?u.pathnameBase:"/"),p=(u&&u.route,b());if(a){var f;let e="string"==typeof a?t.parsePath(a):a;"/"===h||(null==(f=e.pathname)?void 0:f.startsWith(h))||l(!1),r=e}else r=p;let m=r.pathname||"/",d=o(e,{pathname:"/"===h?m:m.slice(h.length)||"/"});return M(d&&d.map((e=>Object.assign({},e,{params:Object.assign({},c,e.params),pathname:v([h,e.pathname]),pathnameBase:"/"===e.pathnameBase?h:v([h,e.pathnameBase])}))),s)}function M(e,t){return void 0===t&&(t=[]),null==e?null:e.reduceRight(((a,r,l)=>n.createElement(i.Provider,{children:void 0!==r.route.element?r.route.element:a,value:{outlet:a,matches:t.concat(e.slice(0,l+1))}})),null)}function N(e){l(!1)}function W(e){let{basename:i="/",children:o=null,location:s,navigationType:u=t.Action.Pop,navigator:c,static:h=!1}=e;C()&&l(!1);let p=y(i),f=n.useMemo((()=>({basename:p,navigator:c,static:h})),[p,c,h]);"string"==typeof s&&(s=t.parsePath(s));let{pathname:m="/",search:d="",hash:v="",state:x=null,key:P="default"}=s,b=n.useMemo((()=>{let e=g(m,p);return null==e?null:{pathname:e,search:d,hash:v,state:x,key:P}}),[p,m,d,v,x,P]);return null==b?null:n.createElement(a.Provider,{value:f},n.createElement(r.Provider,{children:o,value:{location:b,navigationType:u}}))}function j(e){let t=[];return n.Children.forEach(e,(e=>{if(!n.isValidElement(e))return;if(e.type===n.Fragment)return void t.push.apply(t,j(e.props.children));e.type!==N&&l(!1);let a={caseSensitive:e.props.caseSensitive,element:e.props.element,index:e.props.index,path:e.props.path};e.props.children&&(a.children=j(e.props.children)),t.push(a)})),t}Object.defineProperty(e,"NavigationType",{enumerable:!0,get:function(){return t.Action}}),Object.defineProperty(e,"createPath",{enumerable:!0,get:function(){return t.createPath}}),Object.defineProperty(e,"parsePath",{enumerable:!0,get:function(){return t.parsePath}}),e.MemoryRouter=function(e){let{basename:a,children:r,initialEntries:i,initialIndex:l}=e,o=n.useRef();null==o.current&&(o.current=t.createMemoryHistory({initialEntries:i,initialIndex:l}));let s=o.current,[u,c]=n.useState({action:s.action,location:s.location});return n.useLayoutEffect((()=>s.listen(c)),[s]),n.createElement(W,{basename:a,children:r,location:u.location,navigationType:u.action,navigator:s})},e.Navigate=function(e){let{to:t,replace:a,state:r}=e;C()||l(!1);let i=E();return n.useEffect((()=>{i(t,{replace:a,state:r})})),null},e.Outlet=function(e){return S(e.context)},e.Route=N,e.Router=W,e.Routes=function(e){let{children:t,location:n}=e;return O(j(t),n)},e.UNSAFE_LocationContext=r,e.UNSAFE_NavigationContext=a,e.UNSAFE_RouteContext=i,e.createRoutesFromChildren=j,e.generatePath=function(e,t){return void 0===t&&(t={}),e.replace(/:(\w+)/g,((e,n)=>(null==t[n]&&l(!1),t[n]))).replace(/\/*\*$/,(e=>null==t["*"]?"":t["*"].replace(/^\/*/,"/")))},e.matchPath=f,e.matchRoutes=o,e.renderMatches=function(e){return M(e)},e.resolvePath=m,e.useHref=function(e){C()||l(!1);let{basename:r,navigator:i}=n.useContext(a),{hash:o,pathname:s,search:u}=$(e),c=s;if("/"!==r){let n=function(e){return""===e||""===e.pathname?"/":"string"==typeof e?t.parsePath(e).pathname:e.pathname}(e),a=null!=n&&n.endsWith("/");c="/"===s?r+(a?"/":""):v([r,s])}return i.createHref({pathname:c,search:u,hash:o})},e.useInRouterContext=C,e.useLocation=b,e.useMatch=function(e){C()||l(!1);let{pathname:t}=b();return n.useMemo((()=>f(e,t)),[t,e])},e.useNavigate=E,e.useNavigationType=function(){return n.useContext(r).navigationType},e.useOutlet=S,e.useOutletContext=function(){return n.useContext(R)},e.useParams=function(){let{matches:e}=n.useContext(i),t=e[e.length-1];return t?t.params:{}},e.useResolvedPath=$,e.useRoutes=O,Object.defineProperty(e,"__esModule",{value:!0})}));
+!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("history"),require("react")):"function"==typeof define&&define.amd?define(["exports","history","react"],t):t((e=e||self).ReactRouter={},e.HistoryLibrary,e.React)}(this,(function(e,t,n){"use strict";const a=n.createContext(null),r=n.createContext(null),i=n.createContext({outlet:null,matches:[]});function l(e,t){if(!e)throw new Error(t)}function o(e,n,a){void 0===a&&(a="/");let r=g(("string"==typeof n?t.parsePath(n):n).pathname||"/",a);if(null==r)return null;let i=s(e);!function(e){e.sort(((e,t)=>e.score!==t.score?t.score-e.score:function(e,t){return e.length===t.length&&e.slice(0,-1).every(((e,n)=>e===t[n]))?e[e.length-1]-t[t.length-1]:0}(e.routesMeta.map((e=>e.childrenIndex)),t.routesMeta.map((e=>e.childrenIndex)))))}(i);let l=null;for(let e=0;null==l&&e<i.length;++e)l=p(i[e],r);return l}function s(e,t,n,a){return void 0===t&&(t=[]),void 0===n&&(n=[]),void 0===a&&(a=""),e.forEach(((e,r)=>{let i={relativePath:e.path||"",caseSensitive:!0===e.caseSensitive,childrenIndex:r,route:e};i.relativePath.startsWith("/")&&(i.relativePath.startsWith(a)||l(!1),i.relativePath=i.relativePath.slice(a.length));let o=v([a,i.relativePath]),u=n.concat(i);e.children&&e.children.length>0&&(!0===e.index&&l(!1),s(e.children,t,u,o)),(null!=e.path||e.index)&&t.push({path:o,score:h(o,e.index),routesMeta:u})})),t}const u=/^:\w+$/,c=e=>"*"===e;function h(e,t){let n=e.split("/"),a=n.length;return n.some(c)&&(a+=-2),t&&(a+=2),n.filter((e=>!c(e))).reduce(((e,t)=>e+(u.test(t)?3:""===t?1:10)),a)}function p(e,t){let{routesMeta:n}=e,a={},r="/",i=[];for(let e=0;e<n.length;++e){let l=n[e],o=e===n.length-1,s="/"===r?t:t.slice(r.length)||"/",u=f({path:l.relativePath,caseSensitive:l.caseSensitive,end:o},s);if(!u)return null;Object.assign(a,u.params);let c=l.route;i.push({params:a,pathname:v([r,u.pathname]),pathnameBase:y(v([r,u.pathnameBase])),route:c}),"/"!==u.pathnameBase&&(r=v([r,u.pathnameBase]))}return i}function f(e,t){"string"==typeof e&&(e={path:e,caseSensitive:!1,end:!0});let[n,a]=function(e,t,n){void 0===t&&(t=!1);void 0===n&&(n=!0);let a=[],r="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^$?{}|()[\]]/g,"\\$&").replace(/:(\w+)/g,((e,t)=>(a.push(t),"([^\\/]+)")));e.endsWith("*")?(a.push("*"),r+="*"===e||"/*"===e?"(.*)$":"(?:\\/(.+)|\\/*)$"):r+=n?"\\/*$":"(?:(?=[@.~-]|%[0-9A-F]{2})|\\b|\\/|$)";return[new RegExp(r,t?void 0:"i"),a]}(e.path,e.caseSensitive,e.end),r=t.match(n);if(!r)return null;let i=r[0],l=i.replace(/(.)\/+$/,"$1"),o=r.slice(1);return{params:a.reduce(((e,t,n)=>{if("*"===t){let e=o[n]||"";l=i.slice(0,i.length-e.length).replace(/(.)\/+$/,"$1")}return e[t]=function(e,t){try{return decodeURIComponent(e)}catch(t){return e}}(o[n]||""),e}),{}),pathname:i,pathnameBase:l,pattern:e}}function m(e,n){void 0===n&&(n="/");let{pathname:a,search:r="",hash:i=""}="string"==typeof e?t.parsePath(e):e,l=a?a.startsWith("/")?a:function(e,t){let n=t.replace(/\/+$/,"").split("/");return e.split("/").forEach((e=>{".."===e?n.length>1&&n.pop():"."!==e&&n.push(e)})),n.length>1?n.join("/"):"/"}(a,n):n;return{pathname:l,search:x(r),hash:P(i)}}function d(e,n,a){let r,i="string"==typeof e?t.parsePath(e):e,l=""===e||""===i.pathname?"/":i.pathname;if(null==l)r=a;else{let e=n.length-1;if(l.startsWith("..")){let t=l.split("/");for(;".."===t[0];)t.shift(),e-=1;i.pathname=t.join("/")}r=e>=0?n[e]:"/"}let o=m(i,r);return l&&"/"!==l&&l.endsWith("/")&&!o.pathname.endsWith("/")&&(o.pathname+="/"),o}function g(e,t){if("/"===t)return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=e.charAt(t.length);return n&&"/"!==n?null:e.slice(t.length)||"/"}const v=e=>e.join("/").replace(/\/\/+/g,"/"),y=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),x=e=>e&&"?"!==e?e.startsWith("?")?e:"?"+e:"",P=e=>e&&"#"!==e?e.startsWith("#")?e:"#"+e:"";function C(){return null!=n.useContext(r)}function b(){return C()||l(!1),n.useContext(r).location}function E(){C()||l(!1);let{basename:e,navigator:t}=n.useContext(a),{matches:r}=n.useContext(i),{pathname:o}=b(),s=JSON.stringify(r.map((e=>e.pathnameBase))),u=n.useRef(!1);return n.useEffect((()=>{u.current=!0})),n.useCallback((function(n,a){if(void 0===a&&(a={}),!u.current)return;if("number"==typeof n)return void t.go(n);let r=d(n,JSON.parse(s),o);"/"!==e&&(r.pathname=v([e,r.pathname])),(a.replace?t.replace:t.push)(r,a.state)}),[e,t,s,o])}const R=n.createContext(null);function S(e){let t=n.useContext(i).outlet;return t?n.createElement(R.Provider,{value:e},t):t}function $(e){let{matches:t}=n.useContext(i),{pathname:a}=b(),r=JSON.stringify(t.map((e=>e.pathnameBase)));return n.useMemo((()=>d(e,JSON.parse(r),a)),[e,r,a])}function O(e,a){C()||l(!1);let r,{matches:s}=n.useContext(i),u=s[s.length-1],c=u?u.params:{},h=(u&&u.pathname,u?u.pathnameBase:"/"),p=(u&&u.route,b());if(a){var f;let e="string"==typeof a?t.parsePath(a):a;"/"===h||(null==(f=e.pathname)?void 0:f.startsWith(h))||l(!1),r=e}else r=p;let m=r.pathname||"/",d=o(e,{pathname:"/"===h?m:m.slice(h.length)||"/"});return M(d&&d.map((e=>Object.assign({},e,{params:Object.assign({},c,e.params),pathname:v([h,e.pathname]),pathnameBase:"/"===e.pathnameBase?h:v([h,e.pathnameBase])}))),s)}function M(e,t){return void 0===t&&(t=[]),null==e?null:e.reduceRight(((a,r,l)=>n.createElement(i.Provider,{children:void 0!==r.route.element?r.route.element:a,value:{outlet:a,matches:t.concat(e.slice(0,l+1))}})),null)}function N(e){l(!1)}function W(e){let{basename:i="/",children:o=null,location:s,navigationType:u=t.Action.Pop,navigator:c,static:h=!1}=e;C()&&l(!1);let p=y(i),f=n.useMemo((()=>({basename:p,navigator:c,static:h})),[p,c,h]);"string"==typeof s&&(s=t.parsePath(s));let{pathname:m="/",search:d="",hash:v="",state:x=null,key:P="default"}=s,b=n.useMemo((()=>{let e=g(m,p);return null==e?null:{pathname:e,search:d,hash:v,state:x,key:P}}),[p,m,d,v,x,P]);return null==b?null:n.createElement(a.Provider,{value:f},n.createElement(r.Provider,{children:o,value:{location:b,navigationType:u}}))}function j(e){let t=[];return n.Children.forEach(e,(e=>{if(!n.isValidElement(e))return;if(e.type===n.Fragment)return void t.push.apply(t,j(e.props.children));e.type!==N&&l(!1);let a={caseSensitive:e.props.caseSensitive,element:e.props.element,index:e.props.index,path:e.props.path};e.props.children&&(a.children=j(e.props.children)),t.push(a)})),t}Object.defineProperty(e,"NavigationType",{enumerable:!0,get:function(){return t.Action}}),Object.defineProperty(e,"createPath",{enumerable:!0,get:function(){return t.createPath}}),Object.defineProperty(e,"parsePath",{enumerable:!0,get:function(){return t.parsePath}}),e.MemoryRouter=function(e){let{basename:a,children:r,initialEntries:i,initialIndex:l}=e,o=n.useRef();null==o.current&&(o.current=t.createMemoryHistory({initialEntries:i,initialIndex:l}));let s=o.current,[u,c]=n.useState({action:s.action,location:s.location});return n.useLayoutEffect((()=>s.listen(c)),[s]),n.createElement(W,{basename:a,children:r,location:u.location,navigationType:u.action,navigator:s})},e.Navigate=function(e){let{to:t,replace:a,state:r}=e;C()||l(!1);let i=E();return n.useEffect((()=>{i(t,{replace:a,state:r})})),null},e.Outlet=function(e){return S(e.context)},e.Route=N,e.Router=W,e.Routes=function(e){let{children:t,location:n}=e;return O(j(t),n)},e.UNSAFE_LocationContext=r,e.UNSAFE_NavigationContext=a,e.UNSAFE_RouteContext=i,e.createRoutesFromChildren=j,e.generatePath=function(e,t){return void 0===t&&(t={}),e.replace(/:(\w+)/g,((e,n)=>(null==t[n]&&l(!1),t[n]))).replace(/\/*\*$/,(e=>null==t["*"]?"":t["*"].replace(/^\/*/,"/")))},e.matchPath=f,e.matchRoutes=o,e.renderMatches=function(e){return M(e)},e.resolvePath=m,e.useHref=function(e){C()||l(!1);let{basename:r,navigator:i}=n.useContext(a),{hash:o,pathname:s,search:u}=$(e),c=s;if("/"!==r){let n=function(e){return""===e||""===e.pathname?"/":"string"==typeof e?t.parsePath(e).pathname:e.pathname}(e),a=null!=n&&n.endsWith("/");c="/"===s?r+(a?"/":""):v([r,s])}return i.createHref({pathname:c,search:u,hash:o})},e.useInRouterContext=C,e.useLocation=b,e.useMatch=function(e){C()||l(!1);let{pathname:t}=b();return n.useMemo((()=>f(e,t)),[t,e])},e.useNavigate=E,e.useNavigationType=function(){return n.useContext(r).navigationType},e.useOutlet=S,e.useOutletContext=function(){return n.useContext(R)},e.useParams=function(){let{matches:e}=n.useContext(i),t=e[e.length-1];return t?t.params:{}},e.useResolvedPath=$,e.useRoutes=O,Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=react-router.production.min.js.map
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment