Skip to content

Commit

Permalink
fix(frontend/controller): use original line to render search results
Browse files Browse the repository at this point in the history
  • Loading branch information
Harjot1Singh committed Jun 30, 2020
1 parent 37d5150 commit 792fc77
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions app/frontend/src/Controller/Search.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,20 +75,19 @@ const highlightFullWordMatches = ( line, query ) => {
}

const highlightFirstLetterMatches = ( line, query ) => {
const unicodeLine = stripAccents( stripVishraams( toUnicode( line ) ) )
const unicodeQuery = stripAccents( toUnicode( query ) )
const baseLine = stripVishraams( line )

const letters = firstLetters( unicodeLine )
const words = unicodeLine.split( ' ' )
const letters = toAscii( firstLetters( stripAccents( toUnicode( baseLine ) ) ) )
const words = baseLine.split( ' ' )

const startPosition = letters.search( unicodeQuery )
const startPosition = letters.search( stripAccents( query ) )
const endPosition = startPosition + query.length

return [
`${words.slice( 0, startPosition ).join( ' ' )} `,
`${words.slice( startPosition, endPosition ).join( ' ' )} `,
`${words.slice( endPosition ).join( ' ' )} `,
].map( toAscii )
]
}

/**
Expand Down

0 comments on commit 792fc77

Please sign in to comment.