(url: string)
| 51 | |
| 52 | let timeoutId: number | undefined; |
| 53 | const capture = (url: string) => { |
| 54 | if (withoutLayoutVariantPrefix(router.pathname) === '/posts/[id]') { |
| 55 | return; |
| 56 | } |
| 57 | const path = url.split('?')[0].split('#')[0]; |
| 58 | // Only the latest navigation matters — drop any pending capture so |
| 59 | // rapid navigation doesn't stack timers or record stale titles. |
| 60 | window.clearTimeout(timeoutId); |
| 61 | timeoutId = window.setTimeout(() => { |
| 62 | const title = cleanTitle(document.title); |
| 63 | if (title) { |
| 64 | recordRecentPage({ |
| 65 | path, |
| 66 | title, |
| 67 | type: typeForPathname(router.pathname), |
| 68 | }); |
| 69 | } |
| 70 | }, 250); |
| 71 | }; |
| 72 | |
| 73 | capture(router.asPath); |
| 74 | router.events.on('routeChangeComplete', capture); |
no test coverage detected