Skip to content
Snippets Groups Projects
Commit a25cd6de authored by Ole Voldsæter's avatar Ole Voldsæter
Browse files

fikser meta#249

parent 9dc2c095
No related branches found
No related tags found
No related merge requests found
......@@ -139,25 +139,27 @@ export default {
let self = this
return function(q) {
return new Promise(resolve => {
return axios.get(self.api_pref + 'suggest?q=' + q).then(
return axios.get(self.api_pref + 'suggest?q=' + encodeURIComponent(q)).then(
function(response) {
let hits = []
response.data.forEach((item, i) => {
if (! hits[0] || hits[0].word != item.match) {
hits.splice(0, 0, {q: q, lang_set: new Set(), word: item.match, articles: []})
let match = encodeURIComponent(item.match)
if (! hits[0] || hits[0].word != match) {
hits.splice(0, 0, {q: encodeURIComponent(q), lang_set: new Set(), word: match, articles: []})
}
hits[0].lang_set.add(item.dictionary == 'bob' ? 'bm' : 'nn')
hits[0].articles.push(item)
});
hits.forEach(function (hit) {
if (hit.lang_set) {
hit.label = `${hit.word} (${Array.from(hit.lang_set).sort().join(', ')})`
hit.label = `${decodeURIComponent(hit.word)} (${Array.from(hit.lang_set).sort().join(', ')})`
}
});
hits.reverse()
hits = hits.slice(0, 8)
if (q) {
hits.push({q: q, label: q + ' (fritekstsøk)'})
hits.push({q: encodeURIComponent(q), label: q + ' (fritekstsøk)'})
}
resolve(hits)
})
......
......@@ -40,7 +40,7 @@ export default {
type: item.type_,
html: '',
link_text: item.word_form || item.lemmas[0].lemma,
ref: '/' + lang + '/' + item.article_id + '/' + (item.word_form || item.lemmas[0].lemma) + (item.definition_id ? '#def' + item.definition_id : ''),
ref: '/' + lang + '/' + item.article_id + '/' + encodeURIComponent(item.word_form || item.lemmas[0].lemma) + (item.definition_id ? '#def' + item.definition_id : ''),
article_id: item.article_id,
definition_id: item.definition_id,
definition_order: item.definition_order,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment