Merge pull request #59 from Worble/#36_sanitize_search_inputs

encodeUriComponent search query before adding to router path
This commit is contained in:
Preston 2020-08-04 22:12:42 -04:00 committed by GitHub
commit 30b4392a77
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 33 additions and 32 deletions

View File

@ -10,14 +10,14 @@ export default Vue.extend({
name: 'TopNav',
components: {
FtInput,
FtSearchFilters
FtSearchFilters,
},
data: () => {
return {
component: this,
windowWidth: 0,
showFilters: false,
searchSuggestionsDataList: []
searchSuggestionsDataList: [],
}
},
computed: {
@ -82,23 +82,19 @@ export default Vue.extend({
this.$store.dispatch('getVideoIdFromUrl', query).then((result) => {
if (result) {
this.$router.push(
{
this.$router.push({
path: `/watch/${result}`,
}
)
})
} else {
router.push(
{
path: `/search/${query}`,
router.push({
path: `/search/${encodeURIComponent(query)}`,
query: {
sortBy: this.searchSettings.sortBy,
time: this.searchSettings.time,
type: this.searchSettings.type,
duration: this.searchSettings.duration
}
}
)
duration: this.searchSettings.duration,
},
})
}
})
@ -143,16 +139,21 @@ export default Vue.extend({
resource: 'search/suggestions',
id: '',
params: {
q: query
}
q: query,
},
}
this.$store.dispatch('invidiousAPICall', searchPayload).then((results) => {
this.$store
.dispatch('invidiousAPICall', searchPayload)
.then((results) => {
this.searchSuggestionsDataList = results.suggestions
}).error((err) => {
})
.error((err) => {
console.log(err)
if (this.backendFallback) {
console.log('Error gettings search suggestions. Falling back to Local API')
console.log(
'Error gettings search suggestions. Falling back to Local API'
)
this.getSearchSuggestionsLocal(query)
}
})
@ -180,6 +181,6 @@ export default Vue.extend({
toggleSideNav: function () {
this.$store.commit('toggleSideNav')
}
}
},
},
})