Skip to content

fix(extension): revert #377 and cleanly fix same-url navigation timeout#380

Merged
jackwener merged 2 commits intomainfrom
revert-and-fix-same-url-timeout
Mar 24, 2026
Merged

fix(extension): revert #377 and cleanly fix same-url navigation timeout#380
jackwener merged 2 commits intomainfrom
revert-and-fix-same-url-timeout

Conversation

@jackwener
Copy link
Copy Markdown
Owner

Summary

What changed

  • normalizeUrlForComparison: Minimal URL canonicalization — only root slash (/"") and default port. Preserves hash routes and non-root trailing slashes to avoid false matches.
  • Fast-path: Skip navigation entirely when the tab is already at the target URL and fully loaded.
  • Improved wait logic: Uses finish() pattern to prevent double-resolve; handles both same-URL navigations AND redirects (resolves when URL matches target OR URL changed from before).
  • Tests: Same-URL fast-path, hash route distinction, trailing slash distinction.

Differences from #377

Aspect #377 This PR
dist/background.js ~1000 lines of formatting churn Not touched
Hash handling Originally stripped (fixed by codex) Preserved from the start
Redirect handling Would timeout on redirects Handles via OR condition
Cleanup Multiple resolve paths Single finish() with settled flag

Validation

  • cd extension && npx tsc --noEmit
  • npx vitest run --root extension src/background.test.ts ✅ (5 tests)
  • npm test ✅ (231 tests)
  • cd extension && npm run build

Note

extension/dist/background.js is intentionally excluded from this PR to keep the diff clean. It should be rebuilt separately (e.g. cd extension && npm run build).

- Add normalizeUrlForComparison for minimal URL canonicalization
  (root slash + default port only; preserves hash and non-root paths)
- Fast-path: skip navigation when tab is already at the target URL
- Rewrite wait logic with finish() pattern to prevent double-resolve
- Handle both same-URL and redirect scenarios in navigation listener
- Add regression tests for same-URL and hash-route distinction
@jackwener jackwener merged commit 3b2a51f into main Mar 24, 2026
13 checks passed
@jackwener jackwener deleted the revert-and-fix-same-url-timeout branch March 24, 2026 14:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant