feat(ui): extract URLs from pasted text or messages in URL input#95
feat(ui): extract URLs from pasted text or messages in URL input#95miguelAngelo1999 wants to merge 1 commit into
Conversation
692b457 to
136b81e
Compare
- Add extractUrls() to sources.ts: regex pulls all http/https URLs from arbitrary text, deduplicates, strips trailing punctuation - Update parseUniversalUrls() and parseUrls() in DownloadContext and MetadataContext so mixed text like 'download https://... and https://...' works on a single line or multiple lines - Fix countUrls() in UrlInput to count actual URL matches (not lines) - Auto-switch to multi-line mode when 2+ URLs detected on one line - Auto-clean pasted input: replace mixed text with extracted URLs on separate lines - Fix preview: appears when single URL detected within surrounding text
136b81e to
3b362c0
Compare
Users often paste links inside chat messages or surrounding text, so enqueue flows should extract HTTP URLs once in the shared source helper instead of each input assuming one URL per line. The YouTube page keeps its YouTube-only filter while Universal, Gallery, and Metadata share the broader extraction behavior. The Windows Deno test harness also resolves long native paths so Deno permissions match Bun-created temp paths. Constraint: Upstream PR vanloctech#95 only touched MetadataContext, but custom has multiple enqueue surfaces that already share source helpers. Constraint: Bun on Windows can expose TEMP as ADMINI~1 while Deno canonicalizes to Administrator. Rejected: Port upstream PR vanloctech#95 wholesale | it would disturb custom context memoization and miss Universal/Gallery counters. Rejected: Add a new parsing dependency | URL extraction is small and covered by tests. Confidence: high Scope-risk: moderate Directive: Keep pasted URL extraction centralized in src/lib/sources.ts so input surfaces do not drift. Tested: bun run biome check --write . Tested: bun run tsc -b Tested: cargo check in src-tauri Tested: bun test Not-tested: Manual pasted-text enqueue in the installed Tauri UI before this commit.
|
Thanks for the UX improvement idea. Extracting URLs from pasted messages is useful, but this PR cannot be merged in its current form. The PR description says it updates the shared URL parser, DownloadContext, UrlInput counting, paste cleanup, and multiline behavior, but the actual diff only changes There are also TypeScript regressions: Could you please rebase on latest |
|
I prepared a clean follow-up PR here: #99 It follows the maintainer feedback by adding shared |
Pasted links often arrive inside chat messages or surrounding text, so URL input surfaces should extract HTTP(S) URLs once in src/lib/sources.ts and reuse that behavior across Download, Universal, Gallery, and Metadata without changing context architecture. Constraint: Maintainer requested a focused shared helper after PR #95 only touched MetadataContext. Constraint: Metadata fetch must keep existing cookieSkipPatterns behavior. Rejected: Rework context provider exports | unrelated to URL parsing and caused regressions in PR #95. Rejected: Add a parsing dependency | a small URL extractor is enough and test-covered. Confidence: high Scope-risk: moderate Directive: Keep URL counting and enqueue parsing routed through extractUrls so pasted-message behavior does not drift between pages. Tested: bunx biome check --write src/lib/sources.ts src/components/download/UrlInput.tsx src/components/download/UniversalUrlInput.tsx src/components/download/GalleryUrlInput.tsx src/contexts/DownloadContext.tsx src/contexts/MetadataContext.tsx tests/source-url-extraction.test.ts Tested: bun test tests/source-url-extraction.test.ts Tested: bun run tsc -b Not-tested: Full bun run lint on Windows upstream worktree; existing CRLF line endings trigger 356 formatter diagnostics. Not-tested: cargo check in clean PR worktree; missing bundled yt-dlp binary resource bin\\youwee-yt-dlp-x86_64-pc-windows-msvc.exe.
Problem
The URL input fields only accept one clean URL per line. If a user pastes a message like:
...nothing gets added to the queue because none of the lines are a valid URL by themselves.
Solution
Add
extractUrls()tosrc/lib/sources.tsthat:http:///https://URLs from within the text using a regex.,;:!?)) that's commonly attached to URLs in messagesUpdate
parseUniversalUrls(),DownloadContext.parseUrls(), andMetadataContext.parseUrls()to use this logic.Files Changed
src/lib/sources.ts— newextractUrls()utilitysrc/contexts/DownloadContext.tsx— updatedparseUrls()src/contexts/MetadataContext.tsx— updatedparseUrls()