Skip to content

Commit

Permalink
Merge pull request #3655 from nextcloud/backport/3653/stable5.4
Browse files Browse the repository at this point in the history
[stable5.4] fix: improve matching for tel type parameter
  • Loading branch information
st3iny authored Oct 11, 2023
2 parents 894c11c + 912ac3a commit bb749ca
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/components/ContactDetails/ContactDetailsProperty.vue
Original file line number Diff line number Diff line change
Expand Up @@ -251,11 +251,18 @@ export default {
// https://jsperf.com/array-map-and-intersection-perf
const matchingTypes = this.propModel.options
.map(type => {
return {
type,
// "WORK,HOME" => ['WORK', 'HOME']
score: type.id.split(',').filter(value => selectedType.indexOf(value) !== -1).length,
let score = 0
const types = type.id.split(',') // "WORK,HOME" => ['WORK', 'HOME']

if (types.length === selectedType.length) {
// additional point for same length
score++
}

const intersection = types.filter(value => selectedType.includes(value))
score = score + intersection.length

return { type, score }
})

// Sort by score, filtering out the null score and selecting the first match
Expand Down

0 comments on commit bb749ca

Please sign in to comment.