Merge pull request #59 from Worble/#36_sanitize_search_inputs
encodeUriComponent search query before adding to router path
This commit is contained in:
commit
30b4392a77
|
@ -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: {
|
||||
|
@ -57,7 +57,7 @@ export default Vue.extend({
|
|||
searchContainer.style.display = 'none'
|
||||
}
|
||||
|
||||
window.addEventListener('resize', function(event) {
|
||||
window.addEventListener('resize', function (event) {
|
||||
const width = event.srcElement.innerWidth
|
||||
const searchContainer = $('.searchContainer').get(0)
|
||||
|
||||
|
@ -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')
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue