router-kit 0.1.6 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useEffect, useState } from "react";
|
|
3
3
|
import join from "url-join";
|
|
4
|
-
import { routes } from "../core/createRouter";
|
|
5
4
|
import Page404 from "../pages/404";
|
|
6
5
|
import RouterContext from "./RouterContext";
|
|
7
|
-
const RouterProvider = () => {
|
|
6
|
+
const RouterProvider = ({ routes }) => {
|
|
8
7
|
const [path, setPath] = useState(window.location.pathname);
|
|
9
8
|
let fullPathWithParams = "";
|
|
10
9
|
const pathValidation = (routeFullPath, currentPath) => {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
export let routes = [];
|
|
2
1
|
function normalizeRoutes(inputRoutes) {
|
|
3
|
-
|
|
2
|
+
return inputRoutes.map((route) => {
|
|
4
3
|
var _a, _b;
|
|
5
4
|
const normalizedPath = ((_a = route.path) === null || _a === void 0 ? void 0 : _a.startsWith("/"))
|
|
6
5
|
? route.path.replace(/^\/+/, "")
|
|
@@ -14,10 +13,8 @@ function normalizeRoutes(inputRoutes) {
|
|
|
14
13
|
}
|
|
15
14
|
return normalized;
|
|
16
15
|
});
|
|
17
|
-
routes = normalizedRoutes;
|
|
18
|
-
return normalizedRoutes;
|
|
19
16
|
}
|
|
20
17
|
function createRouter(inputRoutes) {
|
|
21
|
-
return
|
|
18
|
+
return normalizeRoutes(inputRoutes);
|
|
22
19
|
}
|
|
23
20
|
export default createRouter;
|
package/package.json
CHANGED