@solidjs/router 0.13.3 → 0.13.4

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 CHANGED
@@ -868,7 +868,7 @@ return <div classList={{ active: Boolean(match()) }} />;
868
868
  For example if you stored breadcrumbs on your route definition you could retrieve them like so:
869
869
  ```js
870
870
  const matches = useCurrentMatches();
871
- const breadcrumbs = createMemo(() => matches.map(m => m.route.info.breadcrumb))
871
+ const breadcrumbs = createMemo(() => matches().map(m => m.route.info.breadcrumb))
872
872
  ```
873
873
 
874
874
  ### useBeforeLeave
@@ -20,7 +20,7 @@ export function A(props) {
20
20
  return [false, false];
21
21
  const path = normalizePath(to_.split(/[?#]/, 1)[0]).toLowerCase();
22
22
  const loc = normalizePath(location.pathname).toLowerCase();
23
- return [props.end ? path === loc : loc.startsWith(path), path === loc];
23
+ return [props.end ? path === loc : loc.startsWith(path + "/") || loc === path, path === loc];
24
24
  });
25
25
  return (<a {...rest} href={href() || props.href} state={JSON.stringify(props.state)} classList={{
26
26
  ...(props.class && { [props.class]: true }),
package/dist/index.d.ts CHANGED
@@ -4,4 +4,4 @@ export * from "./lifecycle.js";
4
4
  export { useHref, useIsRouting, useLocation, useMatch, useCurrentMatches, useNavigate, useParams, useResolvedPath, useSearchParams, useBeforeLeave, } from "./routing.js";
5
5
  export { mergeSearchString as _mergeSearchString } from "./utils.js";
6
6
  export * from "./data/index.js";
7
- export type { Location, LocationChange, NavigateOptions, Navigator, OutputMatch, Params, RouteSectionProps, RouteLoadFunc, RouteLoadFuncArgs, RouteDefinition, RouterIntegration, RouterUtils, SetParams, BeforeLeaveEventArgs } from "./types.js";
7
+ export type { Location, LocationChange, MatchFilter, MatchFilters, NavigateOptions, Navigator, OutputMatch, Params, PathMatch, RouteSectionProps, RouteLoadFunc, RouteLoadFuncArgs, RouteDefinition, Route, RouteMatch, RouterIntegration, RouterUtils, SetParams, BeforeLeaveEventArgs } from "./types.js";
package/dist/index.js CHANGED
@@ -256,7 +256,7 @@ const useMatch = (path, matchFilters) => {
256
256
  }
257
257
  });
258
258
  };
259
- const useCurrentMatches = () => useRouter().matches();
259
+ const useCurrentMatches = () => useRouter().matches;
260
260
  const useParams = () => useRouter().params;
261
261
  const useSearchParams = () => {
262
262
  const location = useLocation();
@@ -1374,7 +1374,7 @@ function HashRouter(props) {
1374
1374
  if (replace) {
1375
1375
  window.history.replaceState(keepDepth(state), "", "#" + value);
1376
1376
  } else {
1377
- window.location.hash = value;
1377
+ window.history.pushState(state, "", "#" + value);
1378
1378
  }
1379
1379
  const hashIndex = value.indexOf("#");
1380
1380
  const hash = hashIndex >= 0 ? value.slice(hashIndex + 1) : "";
@@ -1466,7 +1466,7 @@ function A(props) {
1466
1466
  if (to_ === undefined) return [false, false];
1467
1467
  const path = normalizePath(to_.split(/[?#]/, 1)[0]).toLowerCase();
1468
1468
  const loc = normalizePath(location.pathname).toLowerCase();
1469
- return [props.end ? path === loc : loc.startsWith(path), path === loc];
1469
+ return [props.end ? path === loc : loc.startsWith(path + "/") || loc === path, path === loc];
1470
1470
  });
1471
1471
  return (() => {
1472
1472
  const _el$ = _tmpl$();
@@ -22,7 +22,7 @@ export function HashRouter(props) {
22
22
  window.history.replaceState(keepDepth(state), "", "#" + value);
23
23
  }
24
24
  else {
25
- window.location.hash = value;
25
+ window.history.pushState(state, "", "#" + value);
26
26
  }
27
27
  const hashIndex = value.indexOf("#");
28
28
  const hash = hashIndex >= 0 ? value.slice(hashIndex + 1) : "";
package/dist/routing.d.ts CHANGED
@@ -10,7 +10,7 @@ export declare const useNavigate: () => Navigator;
10
10
  export declare const useLocation: <S = unknown>() => Location<S>;
11
11
  export declare const useIsRouting: () => () => boolean;
12
12
  export declare const useMatch: <S extends string>(path: () => S, matchFilters?: MatchFilters<S> | undefined) => Accessor<import("./types.js").PathMatch | undefined>;
13
- export declare const useCurrentMatches: () => RouteMatch[];
13
+ export declare const useCurrentMatches: () => () => RouteMatch[];
14
14
  export declare const useParams: <T extends Params>() => T;
15
15
  export declare const useSearchParams: <T extends Params>() => [Partial<T>, (params: SetParams, options?: Partial<NavigateOptions>) => void];
16
16
  export declare const useBeforeLeave: (listener: (e: BeforeLeaveEventArgs) => void) => void;
package/dist/routing.js CHANGED
@@ -34,7 +34,7 @@ export const useMatch = (path, matchFilters) => {
34
34
  }
35
35
  });
36
36
  };
37
- export const useCurrentMatches = () => useRouter().matches();
37
+ export const useCurrentMatches = () => useRouter().matches;
38
38
  export const useParams = () => useRouter().params;
39
39
  export const useSearchParams = () => {
40
40
  const location = useLocation();
package/dist/types.d.ts CHANGED
@@ -65,7 +65,7 @@ export type RouteLoadFunc<T = unknown> = (args: RouteLoadFuncArgs) => T;
65
65
  export interface RouteSectionProps<T = unknown> {
66
66
  params: Params;
67
67
  location: Location;
68
- data?: T;
68
+ data: T;
69
69
  children?: JSX.Element;
70
70
  }
71
71
  export type RouteDefinition<S extends string | string[] = any, T = unknown> = {
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  "Ryan Turnquist"
7
7
  ],
8
8
  "license": "MIT",
9
- "version": "0.13.3",
9
+ "version": "0.13.4",
10
10
  "homepage": "https://github.com/solidjs/solid-router#readme",
11
11
  "repository": {
12
12
  "type": "git",