Skip to content

test: use exact hostname matching in mock fetch handlers#764

Open
ital0 wants to merge 2 commits intomainfrom
italomenezes/thu-442-url-sanitization-tests
Open

test: use exact hostname matching in mock fetch handlers#764
ital0 wants to merge 2 commits intomainfrom
italomenezes/thu-442-url-sanitization-tests

Conversation

@ital0
Copy link
Copy Markdown
Collaborator

@ital0 ital0 commented Apr 24, 2026

Replace loose url.includes(...) / url.startsWith(...) in backend test mock fetch handlers with proper hostname parsing via new URL(url).hostname. Fixes 10 CodeQL js/incomplete-url-substring-sanitization alerts (#21#30).

Test plan

  • bun tsc --noEmit (backend) clean
  • bun test --rerun-each 5 on modified files: 170/170 pass
  • prettier + eslint clean on modified files

Note

Low Risk
Low risk: changes are limited to test-only mock fetch URL matching logic and should not affect production behavior beyond making mocks stricter.

Overview
Updates backend tests to stop using loose url.includes(...)/startsWith(...) checks in mocked fetch handlers.

Mocks now parse URLs with new URL(url).hostname and match exact hostnames (including a shared isPosthogRequest helper for PostHog), tightening request classification and addressing CodeQL incomplete URL substring sanitization alerts.

Reviewed by Cursor Bugbot for commit 09589fb. Bugbot is set up for automated code reviews on this repo. Configure here.

@ital0 ital0 self-assigned this Apr 24, 2026
@github-actions
Copy link
Copy Markdown

Semgrep Security Scan

No security issues found.

@ital0 ital0 changed the title test(THU-442): tighten URL matching in mock fetch handlers test: use exact hostname matching in mock fetch handlers Apr 24, 2026
@ital0 ital0 force-pushed the italomenezes/thu-442-url-sanitization-tests branch from 74aa6ba to 3e17310 Compare April 24, 2026 18:34
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 24, 2026

PR Metrics

Metric Value
Lines changed (prod code) +0 / -0
JS bundle size (gzipped) 🟢 1.02 MB → 1.01 MB (-4.4 KB, -0.4%)
Test coverage 🟢 70.64% → 70.64% (+0.0%)
Performance (preview) Preview not ready — Render deploy may have timed out
Accessibility
Best Practices
SEO

Updated Fri, 24 Apr 2026 20:37:31 GMT · run #1200

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