( isSameLevel: (pathname: string) => boolean, fallback: () => void, )
| 317 | // that is not one of them, in one history move so nothing is left to |
| 318 | // replay; the fallback when the stack holds no such page. |
| 319 | export const goBackPast = ( |
| 320 | isSameLevel: (pathname: string) => boolean, |
| 321 | fallback: () => void, |
| 322 | ): string | null => { |
| 323 | const { routes, pointer } = readStack(); |
| 324 | for (let i = pointer - 1; i >= 0; i -= 1) { |
| 325 | if (!isSameLevel(routes[i].path)) { |
| 326 | globalThis.history.go(i - pointer); |
| 327 | return routes[i].path; |
| 328 | } |
| 329 | } |
| 330 | fallback(); |
| 331 | return null; |
| 332 | }; |
| 333 | |
| 334 | // The page the current one was opened from, as this tab's stack recorded it. |
| 335 | export const previousShellPath = (): string | undefined => { |
no test coverage detected