Skip to content

refactor: simplify youtube-url helpers and reduce test duplication#12

Merged
YishenTu merged 2 commits into
mainfrom
youtube-url-gemini-flow
Feb 27, 2026
Merged

refactor: simplify youtube-url helpers and reduce test duplication#12
YishenTu merged 2 commits into
mainfrom
youtube-url-gemini-flow

Conversation

@YishenTu
Copy link
Copy Markdown
Owner

Summary

Simplified the YouTube URL detection module by removing single-use wrapper functions and inlining their logic. Reduced redundant operations and dead code paths. Extracted test helper to eliminate duplication across three related test cases.

Key changes:

  • Removed normalizeHostname, normalizePathname, hasNonEmptyValue wrapper functions
  • Eliminated redundant hostname double-normalization in isYouTubeVideoPath
  • Removed unused isYouTubeUrl export (no production consumers)
  • Collapsed appendVideoUrlPrompt three-way return into single expression
  • Extracted getToolbarButtons test helper to deduplicate button querying

All 67 unit tests pass. TypeScript and Biome lint clean.

Removed single-use wrapper functions (normalizeHostname, normalizePathname, hasNonEmptyValue) and inlined their logic. Eliminated redundant double-normalization of hostnames and removed dead null-guard checks. Collapsed appendVideoUrlPrompt's three-way return into a single expression with computed separator.

Extracted getToolbarButtons helper in regen-flow tests to deduplicate the repeated 3-button query and null-assertion pattern across three tests. Removed unused isYouTubeUrl export which had no production consumers.

All tests pass (67 tests, down from 68 due to removed unused function test).
@YishenTu YishenTu force-pushed the youtube-url-gemini-flow branch from ce71e40 to ca2e5a7 Compare February 27, 2026 16:07
@YishenTu YishenTu merged commit bf0d759 into main Feb 27, 2026
1 check failed
@YishenTu YishenTu deleted the youtube-url-gemini-flow branch February 27, 2026 16:08
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