Resolve URL shorteners and prompt for ambiguous description links

Tapping bit.ly/tinyurl/t.co/etc. in a description or comment previously
opened Safari even when the destination was a playable YouTube URL.
Added an opt-in "Resolve Short Links" toggle under YouTube Enhancements
(off by default) that follows the redirect on tap: if the target is a
YouTube/PeerTube/direct-media URL, open it in-app; otherwise prompt the
user before falling back to yt-dlp extraction or the browser.

Also added a confirmation dialog for non-shortener links that only
matched the loose .externalVideo yt-dlp fallback, so arbitrary web
pages in descriptions no longer silently kick off extraction.

Prompts live on NavigationCoordinator and are dual-hosted by YatteeApp
and ExpandedPlayerSheet so they remain visible whether or not the
expanded player is covering the main view.
This commit is contained in:
Arkadiusz Fal
2026-04-23 07:29:57 +02:00
parent d38b781858
commit 5a839da1bd
13 changed files with 511 additions and 2 deletions

View File

@@ -12,6 +12,18 @@ struct URLRouter: Sendable {
// MARK: - Main Routing
/// Route a URL only if we are *confident* the app can handle it natively
/// YouTube/PeerTube video/channel/playlist, direct media (mp4/m3u8/etc),
/// or the custom `yattee://` scheme. Unlike `route(_:)` this deliberately
/// skips the `.externalVideo` yt-dlp fallback, which matches almost any
/// http/https URL and is therefore unsafe to trigger blindly after
/// resolving a URL shortener.
func routeConfidently(_ url: URL) -> NavigationDestination? {
guard let destination = route(url) else { return nil }
if case .externalVideo = destination { return nil }
return destination
}
/// Route a URL to a navigation destination.
func route(_ url: URL) -> NavigationDestination? {
// Try custom scheme first