Parse IV search urls (#3849)

* parse iv search urls

* Move removing query params to if
This commit is contained in:
ChunkyProgrammer 2023-08-06 05:21:45 -07:00 committed by GitHub
parent 072066fbe1
commit 5fffe83237
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -324,7 +324,7 @@ const actions = {
const typePatterns = new Map([
['playlist', /^(\/playlist\/?|\/embed(\/?videoseries)?)$/],
['search', /^\/results\/?$/],
['search', /^\/results|search\/?$/],
['hashtag', hashtagPattern],
['channel', channelPattern]
])
@ -359,13 +359,21 @@ const actions = {
}
case 'search': {
if (!url.searchParams.has('search_query')) {
let searchQuery = null
if (url.searchParams.has('search_query')) {
// https://www.youtube.com/results?search_query={QUERY}
searchQuery = url.searchParams.get('search_query')
url.searchParams.delete('search_query')
}
if (url.searchParams.has('q')) {
// https://redirect.invidious.io/search?q={QUERY}
searchQuery = url.searchParams.get('q')
url.searchParams.delete('q')
}
if (searchQuery == null) {
throw new Error('Search: "search_query" field not found')
}
const searchQuery = url.searchParams.get('search_query')
url.searchParams.delete('search_query')
const searchSettings = state.searchSettings
const query = {
sortBy: searchSettings.sortBy,