Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

wouter

Package Overview
Dependencies
Maintainers
1
Versions
97
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

wouter - npm Package Compare versions

Comparing version
3.5.1
to
3.6.0
+16
-4
esm/memory-location.js

@@ -10,7 +10,15 @@ import mitt from 'mitt';

path = "/",
searchPath = "",
static: staticLocation,
record,
} = {}) => {
let currentPath = path;
const history = [currentPath];
let initialPath = path;
if (searchPath) {
// join with & if path contains search query, and ? otherwise
initialPath += path.split("?")[1] ? "&" : "?";
initialPath += searchPath;
}
let [currentPath, currentSearch = ""] = initialPath.split("?");
const history = [initialPath];
const emitter = mitt();

@@ -27,3 +35,3 @@

currentPath = path;
[currentPath, currentSearch = ""] = path.split("?");
emitter.emit("navigate", path);

@@ -44,2 +52,5 @@ };

const useMemoryQuery = () =>
useSyncExternalStore(subscribe, () => currentSearch);
function reset() {

@@ -49,3 +60,3 @@ // clean history array with mutation to preserve link

navigateImplementation(path);
navigateImplementation(initialPath);
}

@@ -55,2 +66,3 @@

hook: useMemoryLocation,
searchHook: useMemoryQuery,
navigate,

@@ -57,0 +69,0 @@ history: record ? history : undefined,

+1
-1
{
"name": "wouter",
"version": "3.5.1",
"version": "3.6.0",
"description": "Minimalist-friendly ~1.5KB router for React",

@@ -5,0 +5,0 @@ "type": "module",

@@ -1,2 +0,7 @@

import { BaseLocationHook, Path } from "./location-hook.js";
import {
BaseLocationHook,
BaseSearchHook,
Path,
SearchString,
} from "./location-hook.js";

@@ -8,3 +13,7 @@ type Navigate<S = any> = (

type HookReturnValue = { hook: BaseLocationHook; navigate: Navigate };
type HookReturnValue = {
hook: BaseLocationHook;
searchHook: BaseSearchHook;
navigate: Navigate;
};
type StubHistory = { history: Path[]; reset: () => void };

@@ -14,2 +23,3 @@

path?: Path;
searchPath?: SearchString;
static?: boolean;

@@ -20,4 +30,5 @@ record?: false;

path?: Path;
searchPath?: SearchString;
static?: boolean;
record: true;
}): HookReturnValue & StubHistory;