mirror of
https://github.com/ThatGuySam/doesitarm.git
synced 2026-05-15 06:35:20 -07:00
Use whole word regex matches for descriptions
This commit is contained in:
parent
fa222d3116
commit
d434b19c9b
5 changed files with 74 additions and 41 deletions
|
|
@ -6,6 +6,10 @@ import { byTimeThenNull } from './sort-list.js'
|
|||
import { getVideoEndpoint } from './app-derived.js'
|
||||
import parseGithubDate from './parse-github-date'
|
||||
|
||||
export function matchesWholeWord (needle, haystack) {
|
||||
return new RegExp('\\b' + needle + '\\b').test(haystack)
|
||||
}
|
||||
|
||||
const videoFeaturesApp = function (app, video) {
|
||||
const appFuzzyName = app.name.toLowerCase()
|
||||
if (video.title.toLowerCase().includes(appFuzzyName)) return true
|
||||
|
|
@ -14,7 +18,7 @@ const videoFeaturesApp = function (app, video) {
|
|||
|
||||
if (appIsInTimestamps) return true
|
||||
|
||||
if (video.description.toLowerCase().includes(appFuzzyName)) return true
|
||||
if (matchesWholeWord(appFuzzyName, video.description.toLowerCase())) return true
|
||||
|
||||
return false
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue