preact-hashish-router 0.0.10 → 0.0.12

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/dist/Router.d.ts CHANGED
@@ -2,6 +2,15 @@ import { PropsWithChildren } from "preact/compat";
2
2
  import { RouterContext } from "./context";
3
3
  type RouterProps = PropsWithChildren & {
4
4
  type: RouterContext["type"];
5
+ /**
6
+ * Only for `hash` routers.
7
+ *
8
+ * Decide if the initial pathname will be rewrite as the initial hash.
9
+ *
10
+ * `Caution`: This will replace the initial url hash
11
+ * @default false
12
+ */
13
+ redirect_path_to_hash?: boolean;
5
14
  };
6
15
  export declare const Router: (props: RouterProps) => import("preact").JSX.Element;
7
16
  export {};
package/dist/Router.js CHANGED
@@ -44,9 +44,11 @@ export const Router = (props) => {
44
44
  const [path, query] = get_hash_route().split("?");
45
45
  setQuery(query || "");
46
46
  setPath(path);
47
- if (location.pathname !== "/") {
48
- location.hash = location.pathname;
49
- location.pathname = "";
47
+ if (props.redirect_path_to_hash === true) {
48
+ if (location.pathname !== "/") {
49
+ location.hash = location.pathname;
50
+ location.pathname = "";
51
+ }
50
52
  }
51
53
  hashEffectHandler.effect();
52
54
  return () => hashEffectHandler.cleanUp();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "preact-hashish-router",
3
- "version": "0.0.10",
3
+ "version": "0.0.12",
4
4
  "type": "module",
5
5
  "module": "dist/index.js",
6
6
  "description": "A simple router for preact",
@@ -28,7 +28,14 @@
28
28
  "hash"
29
29
  ],
30
30
  "target": "es2020",
31
- "author": "LiasCode",
31
+ "author": {
32
+ "name": "LiasCode",
33
+ "email": "liascode.dev@gmail.com",
34
+ "url": "https://lias-code.pages.dev"
35
+ },
36
+ "repository": {
37
+ "url": "https://github.com/LiasCode/preact-hashish-router"
38
+ },
32
39
  "devDependencies": {
33
40
  "@preact/preset-vite": "^2.10.1",
34
41
  "@types/node": "^22.13.4",