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