From a25cd6de093a7e5a71e2d4d7447f0314d2971d82 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ole=20Volds=C3=A6ter?= <ole.voldsater@uib.no>
Date: Thu, 28 Jan 2021 11:34:33 +0100
Subject: [PATCH] fikser meta#249

---
 src/App.vue                   | 12 +++++++-----
 src/components/DefElement.vue |  2 +-
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/src/App.vue b/src/App.vue
index 55f5341..dd55792 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -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)
                                       })
diff --git a/src/components/DefElement.vue b/src/components/DefElement.vue
index 67bb56f..2e7ad32 100644
--- a/src/components/DefElement.vue
+++ b/src/components/DefElement.vue
@@ -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,
-- 
GitLab