@aminnairi/react-router 4.0.0 → 4.0.1
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.
- package/README.md +17 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -3
- package/package.json +7 -3
package/README.md
CHANGED
|
@@ -29,6 +29,8 @@ Type-safe router for the React library
|
|
|
29
29
|
- [Contributing](../CONTRIBUTING.md)
|
|
30
30
|
- [Changelogs](#changelogs)
|
|
31
31
|
- [Versions](#versions)
|
|
32
|
+
- [4.0.1](#401)
|
|
33
|
+
- [4.0.0](#400)
|
|
32
34
|
- [3.0.0](#300)
|
|
33
35
|
- [2.1.0](#210)
|
|
34
36
|
- [2.0.1](#201)
|
|
@@ -936,6 +938,7 @@ See [`LICENSE`](./LICENSE).
|
|
|
936
938
|
|
|
937
939
|
### Versions
|
|
938
940
|
|
|
941
|
+
- [`4.0.1`](#401)
|
|
939
942
|
- [`4.0.0`](#400)
|
|
940
943
|
- [`3.0.2`](#302)
|
|
941
944
|
- [`3.0.1`](#301)
|
|
@@ -963,6 +966,20 @@ See [`LICENSE`](./LICENSE).
|
|
|
963
966
|
|
|
964
967
|
- Fixed lint error in the source code dependencies.
|
|
965
968
|
|
|
969
|
+
### 4.0.1
|
|
970
|
+
|
|
971
|
+
#### Major changes
|
|
972
|
+
|
|
973
|
+
None.
|
|
974
|
+
|
|
975
|
+
#### Minor changes
|
|
976
|
+
|
|
977
|
+
None.
|
|
978
|
+
|
|
979
|
+
#### Bug & security fixes
|
|
980
|
+
|
|
981
|
+
- Fixed path normalization to preserve case-sensitivity in dynamic path segments (e.g., `/users/:userIdentifier`).
|
|
982
|
+
|
|
966
983
|
### 3.0.2
|
|
967
984
|
|
|
968
985
|
#### Major changes
|
package/dist/index.d.ts
CHANGED
|
@@ -21,6 +21,7 @@ export interface RouterContextInterface<Locale> {
|
|
|
21
21
|
setLocale: Dispatch<SetStateAction<Locale | null>>;
|
|
22
22
|
}
|
|
23
23
|
export type NavigationDirection = "forward" | "backward";
|
|
24
|
+
export declare function normalize(uri: string): string;
|
|
24
25
|
export declare class Uri<Locale> {
|
|
25
26
|
readonly path: string;
|
|
26
27
|
readonly prefix: string | null;
|
package/dist/index.js
CHANGED
|
@@ -39,7 +39,7 @@ var import_jsx_runtime = (/* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
39
39
|
module.exports = require_react_jsx_runtime_production();
|
|
40
40
|
})))();
|
|
41
41
|
function normalize(uri) {
|
|
42
|
-
return uri.trim().
|
|
42
|
+
return uri.trim().replace(/\/+/g, "/").replace(/^\/+|\/$/g, "");
|
|
43
43
|
}
|
|
44
44
|
function matchPath(path, pathname) {
|
|
45
45
|
const pathParts = normalize(path).split("/").filter(Boolean);
|
|
@@ -251,7 +251,7 @@ function createRouter({ prefix: expectedPrefix, locales, pages, fallback: Fallba
|
|
|
251
251
|
const { prefix } = usePrefix();
|
|
252
252
|
return useCallback((...[params]) => {
|
|
253
253
|
const path = Object.entries(params ?? {}).reduce((oldParams, [name, value]) => {
|
|
254
|
-
return oldParams.replace(`:${name}`, String(value));
|
|
254
|
+
return oldParams.replace(new RegExp(`:${name}`, "g"), String(value));
|
|
255
255
|
}, page.path);
|
|
256
256
|
const pathname = `/${normalize(`${prefix ?? ""}/${locale ?? ""}/${path}`)}`;
|
|
257
257
|
console.log({ pathname });
|
|
@@ -350,4 +350,4 @@ function createRouter({ prefix: expectedPrefix, locales, pages, fallback: Fallba
|
|
|
350
350
|
};
|
|
351
351
|
}
|
|
352
352
|
//#endregion
|
|
353
|
-
export { Uri, createPage, createRouter, crossFadeTransition, scaleFadeTransition, slideHorizontalTransition, slideVerticalTransition };
|
|
353
|
+
export { Uri, createPage, createRouter, crossFadeTransition, normalize, scaleFadeTransition, slideHorizontalTransition, slideVerticalTransition };
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "@aminnairi/react-router",
|
|
4
4
|
"description": "Type-safe router for the React library",
|
|
5
|
-
"version": "4.0.
|
|
5
|
+
"version": "4.0.1",
|
|
6
6
|
"homepage": "https://github.com/aminnairi/react-router",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"types": "dist/index.d.ts",
|
|
@@ -36,15 +36,19 @@
|
|
|
36
36
|
},
|
|
37
37
|
"scripts": {
|
|
38
38
|
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
|
|
39
|
-
"build": "tsc && rolldown --config rolldown.config.ts"
|
|
39
|
+
"build": "tsc && rolldown --config rolldown.config.ts",
|
|
40
|
+
"test": "vitest run",
|
|
41
|
+
"test:watch": "vitest"
|
|
40
42
|
},
|
|
41
43
|
"devDependencies": {
|
|
42
44
|
"@types/react": "^19.2.14",
|
|
43
45
|
"@typescript-eslint/eslint-plugin": "^7.2.0",
|
|
44
46
|
"@typescript-eslint/parser": "^7.2.0",
|
|
47
|
+
"@vitest/coverage-v8": "^2.1.9",
|
|
45
48
|
"eslint": "^8.57.0",
|
|
46
49
|
"eslint-plugin-react-hooks": "^4.6.0",
|
|
47
50
|
"rolldown": "^1.0.0-rc.9",
|
|
48
|
-
"typescript": "^5.9.3"
|
|
51
|
+
"typescript": "^5.9.3",
|
|
52
|
+
"vitest": "^2.0.0"
|
|
49
53
|
}
|
|
50
54
|
}
|