Skip to content

Commit

Permalink
Fix search suggestions for Invidious
Browse files Browse the repository at this point in the history
  • Loading branch information
ChunkyProgrammer committed Oct 31, 2023
1 parent 19b90a5 commit 9e5602f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/renderer/components/top-nav/top-nav.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import FtProfileSelector from '../ft-profile-selector/ft-profile-selector.vue'
import debounce from 'lodash.debounce'

import { IpcChannels } from '../../../constants'
import { openInternalPath } from '../../helpers/utils'
import { decodeHTML, openInternalPath } from '../../helpers/utils'
import { clearLocalSearchSuggestionsSession, getLocalSearchSuggestions } from '../../helpers/api/local'
import { invidiousAPICall } from '../../helpers/api/invidious'

Expand Down Expand Up @@ -258,7 +258,7 @@ export default defineComponent({
}

invidiousAPICall(searchPayload).then((results) => {
this.searchSuggestionsDataList = results.suggestions
this.searchSuggestionsDataList = results.suggestions.map(suggestion => decodeHTML(suggestion))
}).catch((err) => {
console.error(err)
if (process.env.IS_ELECTRON && this.backendFallback) {
Expand Down
11 changes: 11 additions & 0 deletions src/renderer/helpers/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -664,6 +664,17 @@ export function escapeHTML(untrusted) {
.replaceAll('\'', ''')
}

/**
* Decode an html encoded string (for when we're not displaying something as html)
* @param {string} htmlEncodedString
* @returns {string}
*/
export function decodeHTML(htmlEncodedString) {
const testDiv = document.createElement('div')
testDiv.innerHTML = htmlEncodedString
return testDiv.innerText
}

/**
* Performs a deep copy of a javascript object
* @param {Object} obj
Expand Down

0 comments on commit 9e5602f

Please sign in to comment.