Skip to content

Commit

Permalink
Strip tags in autocomplete results
Browse files Browse the repository at this point in the history
  • Loading branch information
abulte committed Sep 5, 2017
1 parent 1fc287e commit 5070bea
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
[#1101](https://github.com/opendatateam/udata/pull/1101)
- Fix facets labelizer with html handling
[#1102](https://github.com/opendatateam/udata/issues/1102)
- Strip tags in autocomplete results
[#1104](https://github.com/opendatateam/udata/pull/1104)

## 1.1.2 (2017-09-04)

Expand Down
10 changes: 7 additions & 3 deletions js/components/site-search.vue
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,14 @@ export default {
default: `<div class="logo">
<img :src="item.image_url || placeholders.generic" class="avatar" width="30" height="30" alt="">
</div>
<p v-html="item.title | highlight query"></p>`,
<p v-html="item.title | stripTags | highlight query"></p>`,
organization: `<div class="logo"><img :src="item.image_url || placeholders.organization" class="avatar" width="30" height="30" alt=""></div>
<p v-html="item.name | highlight query"></p>
<p v-html="item.name | stripTags | highlight query"></p>
<small v-if="item.acronym" v-html="item.acronym | highlight query"></small>`,
territory: `<div class="logo">
<img :src="item.image_url || placeholders.territory" class="avatar" width="30" height="30" alt="">
</div>
<p v-html="item.title | highlight query"></p>
<p v-html="item.title | stripTags | highlight query"></p>
<small v-if="item.parent">{{ item.parent }}</small>`,
},
methods: {
Expand Down Expand Up @@ -146,6 +146,10 @@ export default {
filters: {
highlight(value, phrase) {
return value.replace(new RegExp('('+phrase+')', 'gi'), '<strong>$1</strong>')
},
stripTags(value) {
let regex = /(<([^>]+)>)/ig;
return value.replace(regex, '');
}
},
watch: {
Expand Down

0 comments on commit 5070bea

Please sign in to comment.