From d47ecb27232fc4e06df7aa3fb102b35505f3cfe1 Mon Sep 17 00:00:00 2001 From: Arkadiusz Fal Date: Sat, 23 Sep 2023 21:22:43 +0200 Subject: [PATCH] Fix parsing playlist urls (with list parameter) --- Shared Tests/URLParserTests.swift | 1 + Shared/Navigation/Sidebar.swift | 4 +++- Shared/URLParser.swift | 5 ++++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Shared Tests/URLParserTests.swift b/Shared Tests/URLParserTests.swift index ff6465d9..c7f3e6a3 100644 --- a/Shared Tests/URLParserTests.swift +++ b/Shared Tests/URLParserTests.swift @@ -39,6 +39,7 @@ final class URLParserTests: XCTestCase { "https://www.youtube.com/playlist?list=PLDIoUOhQQPlXr63I_vwF9GD8sAKh77dWU": "PLDIoUOhQQPlXr63I_vwF9GD8sAKh77dWU", "https://www.youtube.com/watch?v=playlist&list=PLDIoUOhQQPlXr63I_vwF9GD8sAKh77dWU": "PLDIoUOhQQPlXr63I_vwF9GD8sAKh77dWU", "youtube.com/watch?v=playlist&list=PLDIoUOhQQPlXr63I_vwF9GD8sAKh77dWU": "PLDIoUOhQQPlXr63I_vwF9GD8sAKh77dWU", + "https://www.youtube.com/watch?v=ZyhrYis509A&list=PL7DA3D097D6FDBC02": "PL7DA3D097D6FDBC02", "/watch?v=playlist&list=PLDIoUOhQQPlXr63I_vwF9GD8sAKh77dWU": "PLDIoUOhQQPlXr63I_vwF9GD8sAKh77dWU", "watch?v=playlist&list=PLDIoUOhQQPlXr63I_vwF9GD8sAKh77dWU": "PLDIoUOhQQPlXr63I_vwF9GD8sAKh77dWU", "playlist?list=ABCDE": "ABCDE" diff --git a/Shared/Navigation/Sidebar.swift b/Shared/Navigation/Sidebar.swift index 37284357..29ce7dc7 100644 --- a/Shared/Navigation/Sidebar.swift +++ b/Shared/Navigation/Sidebar.swift @@ -147,7 +147,9 @@ struct Sidebar: View { } } - private func scrollScrollViewToItem(scrollView: ScrollViewProxy, for selection: TabSelection) { + private func scrollScrollViewToItem(scrollView: ScrollViewProxy, for selection: TabSelection!) { + guard let selection else { return } + if case .recentlyOpened = selection { scrollView.scrollTo("recentlyOpened") return diff --git a/Shared/URLParser.swift b/Shared/URLParser.swift index 2f0597d4..e17e5c32 100644 --- a/Shared/URLParser.swift +++ b/Shared/URLParser.swift @@ -39,7 +39,10 @@ struct URLParser { if hasAnyOfPrefixes(path, ["popular"]) { return .popular } if hasAnyOfPrefixes(path, ["trending"]) { return .trending } - if hasAnyOfPrefixes(path, Self.prefixes[.playlist]!) || queryItemValue("v") == "playlist" { + if hasAnyOfPrefixes(path, Self.prefixes[.playlist]!) || + queryItemValue("v") == "playlist" || + !(queryItemValue("list")?.isEmpty ?? false) + { return .playlist } if hasAnyOfPrefixes(path, Self.prefixes[.channel]!) {