Fix YouTube share links including port from Invidious instance

Fixes #870 where YouTube share links incorrectly included the port number
from the user's Invidious instance URL (e.g., http://www.youtube.com:3000
instead of http://www.youtube.com).

Added defensive logic to explicitly clear the port when creating share URLs
with frontend URL strings containing "youtube.com". This ensures YouTube
share links always use the standard format without port numbers, regardless
of the user's instance configuration.
This commit is contained in:
Arkadiusz Fal
2025-11-23 12:00:02 +01:00
parent aa703f6531
commit 41a33634ee

View File

@@ -114,6 +114,10 @@ extension VideosAPI {
let frontendURL = URL(string: frontendURLString)
{
urlComponents = URLComponents(url: frontendURL, resolvingAgainstBaseURL: false)
// Ensure port is not included when sharing to external frontends like YouTube
if frontendURLString.contains("youtube.com") {
urlComponents?.port = nil
}
} else if let instanceComponents = account?.instance?.urlComponents {
urlComponents = instanceComponents
}