Skip to content

Commit 3b570fa

Browse files
committed
fix(resolve-initial-context): make options parameter optional in resolveInitialContext
1 parent 6c67126 commit 3b570fa

3 files changed

Lines changed: 12 additions & 2 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@equinor/fusion-framework-plugin-context-navigation": patch
3+
---
4+
5+
Fix `createPathAdapter` matching on non-app routes. `canHandle` now rejects a URL when `currentURL.pathname` does not parse as a valid app route (e.g. portal chrome), preventing the path adapter from incorrectly claiming ownership of URLs where there is no app route to encode context into.

packages/modules/context/src/utils/resolve-initial-context.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export const resolveContextFromParent: ContextModuleConfig['resolveInitialContex
3434
// Deliberately co-located with resolveContextFromParent, which it composes with
3535
// fusion-lint-disable-next-line single-export-per-file
3636
export const resolveInitialContext =
37-
(options: {
37+
(options?: {
3838
path?: ContextPathResolveArgs;
3939
}): Required<ContextModuleConfig>['resolveInitialContext'] =>
4040
({ ref, modules }) => {

packages/plugins/context-navigation/src/adapters/create-path-adapter.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,17 @@ export function createPathAdapter(): ContextNavigationAdapter {
4141
* Accepts apps with explicit `'path'` strategy or no declared strategy
4242
* (the path adapter serves as the system-wide default fallback).
4343
*/
44-
canHandle({ appContext, routingStrategy }: AdapterResolutionContext): boolean {
44+
canHandle({ appContext, routingStrategy, currentURL }: AdapterResolutionContext): boolean {
4545
// Custom generators mean the app owns its URL shape — the custom adapter handles it, not us
4646
if (hasCustomContextGenerators(appContext)) {
4747
return false;
4848
}
4949

50+
// Not an app route (e.g. portal chrome) — nothing for this adapter to encode context into
51+
if (!parseAppRoute(currentURL.pathname)) {
52+
return false;
53+
}
54+
5055
const declared = routingStrategy;
5156
// App explicitly opted into path-segment routing — take ownership
5257
if (declared === 'path') {

0 commit comments

Comments
 (0)