-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Closed
Labels
Awaiting PaymentAuto-added when associated PR is deployed to productionAuto-added when associated PR is deployed to productionInternalRequires API changes or must be handled by Expensify staffRequires API changes or must be handled by Expensify staffWeeklyKSv2KSv2
Description
Description
Current State:
getAdaptedStateFromPath.tshandles URL-to-navigation-state conversion- The
getMatchingFullScreenRoute()function checks forbackToparameters - Dynamic suffixes are not recognized; they fall through to standard route matching
- Any URL can be manually constructed with any suffix (no access control)
Expected State:
- Modify
getMatchingFullScreenRoute()to detect dynamic suffixes BEFORE checkingbackTo - Implement access control that validates the base screen is in the
entryScreensallow-list - When a dynamic suffix is detected:
- Strip the suffix from the path
- Get the navigation state for the base path
- Validate the base screen is in
entryScreens - Build the dynamic route state on top of the base state
- This enables proper state restoration after page refresh or deep link
Part A: Suffix Interception
Add new logic before the existing isRouteWithBackToParam check:
function getMatchingFullScreenRoute(route) {
const suffix = getLastSuffixFromPath(route.path);
// NEW: Check for dynamic suffix BEFORE checking backTo
if (isDynamicRouteSuffix(suffix)) {
const pathWithoutSuffix = removeSuffix(route.path, suffix);
const stateUnderneath = getStateFromPath(pathWithoutSuffix, config);
// ... validate and return appropriate state
}
// EXISTING: Check for backTo param
if (isRouteWithBackToParam(route)) {
// ... existing logic
}
}Part B: Access Control Validation
Extend the suffix interception logic to validate entry screens:
if (isDynamicRouteSuffix(suffix)) {
const dynamicConfig = getDynamicConfigBySuffix(suffix);
const baseScreen = findFocusedRoute(baseState);
if (baseScreen && allowedEntryScreens.includes(baseScreen.name)) {
// ALLOW: Generate the dynamic route state
return generateDynamicState(baseState, suffix);
} else {
// DENY: Log error and fall through to standard handling
console.warn(`Access denied: Screen ${baseScreen?.name} is not in entryScreens for ${suffix}`);
}
}Scope
Files:
App/src/libs/Navigation/helpers/getAdaptedStateFromPath.ts- Main modification pointApp/src/libs/Navigation/Navigation.ts- Add validation increateDynamicRoute()
Functions to Add/Modify:
getMatchingFullScreenRoute()- Add suffix detection and validationgetLastSuffixFromPath(),isDynamicRouteSuffix(),removeSuffix()- New helpersgetDynamicConfigBySuffix()- New helper to retrieve config by suffix
Dependencies:
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Awaiting PaymentAuto-added when associated PR is deployed to productionAuto-added when associated PR is deployed to productionInternalRequires API changes or must be handled by Expensify staffRequires API changes or must be handled by Expensify staffWeeklyKSv2KSv2