@stackflow/plugin-history-sync
Advanced tools
Comparing version 1.4.0 to 1.5.0
@@ -340,2 +340,5 @@ "use strict"; | ||
const fallbackActivityPath = fallbackActivityRoute == null ? void 0 : fallbackActivityRoute.path; | ||
const fallbackActivityParams = urlSearchParamsToMap( | ||
pathToUrl(currentPath).searchParams | ||
); | ||
return [ | ||
@@ -345,3 +348,3 @@ (0, import_core.makeEvent)("Pushed", { | ||
activityName: fallbackActivityName, | ||
activityParams: {}, | ||
activityParams: __spreadValues({}, fallbackActivityParams), | ||
eventDate: new Date().getTime() - MINUTE, | ||
@@ -348,0 +351,0 @@ activityContext: { |
import type { Route } from "./RouteLike"; | ||
export declare function pathToUrl(path: string): URL; | ||
export declare function urlSearchParamsToMap(urlSearchParams: URLSearchParams): { | ||
[key: string]: any; | ||
}; | ||
/** | ||
@@ -3,0 +7,0 @@ * import { UrlPatternOptions } from "url-pattern" |
{ | ||
"name": "@stackflow/plugin-history-sync", | ||
"version": "1.4.0", | ||
"version": "1.5.0", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/daangn/stackflow.git", | ||
"directory": "extensions/plugin-history-sync" | ||
}, | ||
"license": "MIT", | ||
@@ -5,0 +10,0 @@ "exports": { |
@@ -1296,2 +1296,33 @@ import type { | ||
}); | ||
test("historySyncPlugin - search param이 붙은 채로 fallback activity로 이동하는 경우 activity params로 만들어줍니다", async () => { | ||
history = createMemoryHistory({ | ||
initialEntries: ["/not/found/route/?foo=1&bar=2"], | ||
}); | ||
const coreStore = stackflow({ | ||
activityNames: ["Home", "Article"], | ||
plugins: [ | ||
historySyncPlugin({ | ||
history, | ||
routes: { | ||
Home: "/home", | ||
Article: "/articles/:articleId", | ||
}, | ||
fallbackActivity: () => "Home", | ||
}), | ||
], | ||
}); | ||
actions = makeActionsProxy({ | ||
actions: coreStore.actions, | ||
}); | ||
const stack = await actions.getStack(); | ||
expect(activeActivity(stack)?.name).toEqual("Home"); | ||
expect(activeActivity(stack)?.params.foo).toEqual("1"); | ||
expect(activeActivity(stack)?.params.bar).toEqual("2"); | ||
expect(path(history.location)).toEqual("/home/?foo=1&bar=2"); | ||
}); | ||
}); |
@@ -5,7 +5,7 @@ import UrlPattern from "url-pattern"; | ||
function pathToUrl(path: string) { | ||
export function pathToUrl(path: string) { | ||
return new URL(path, "file://"); | ||
} | ||
function urlSearchParamsToMap(urlSearchParams: URLSearchParams) { | ||
export function urlSearchParamsToMap(urlSearchParams: URLSearchParams) { | ||
const map: { [key: string]: any } = {}; | ||
@@ -12,0 +12,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
182138
3399
0
46