johman10 / flood-for-transmission

A Flood (https://github.com/Flood-UI/flood) clone for Transmission
GNU General Public License v3.0
353 stars 33 forks source link

Better regex for search and allow searching non ASCII chars #579

Closed iveney closed 1 week ago

iveney commented 5 months ago

for #129

Some test cases:

> regex = /[ \[\]\.·_-]/g

> str1='[这是一部中文电影.Movie.With.Chinese.Title.2024.1080p.WEB-DL.HEVC.10bit.DTS5.1.2Audios-Release]'
'[这是一部中文电影.Movie.With.Chinese.Title.2024.1080p.WEB-DL.HEVC.10bit.DTS5.1.2Audios-Release]'
> str2='English.Movie.2024.1080p.WEB-DL.HEVC.10bit.DTS5.1.2Audios-Release]'
'English.Movie.2024.1080p.WEB-DL.HEVC.10bit.DTS5.1.2Audios-Release]'

> search1 = '中文'
'中文'
> search2 = 'English Movie'
'English Movie'

> str1.toLowerCase().replace(regex, '')
'这是一部中文电影moviewithchinesetitle20241080pwebdlhevc10bitdts512audiosrelease'
> str2.toLowerCase().replace(regex, '')
'englishmovie20241080pwebdlhevc10bitdts512audiosrelease'
> search1.toLowerCase().replace(regex, ' ')
'中文'
> search2.toLowerCase().replace(regex, ' ')
'english movie'
> search1.toLowerCase().replace(regex, '')
'中文'
> search2.toLowerCase().replace(regex, '')
'englishmovie'
> str1.toLowerCase().replace(regex, '').includes(search1.toLowerCase().replace(regex,''))
true
> str2.toLowerCase().replace(regex, '').includes(search2.toLowerCase().replace(regex,''))
true

Also tested locally in my transmission docker that points to the dev version of UI and it's working.

Cannot figure out how to get CORS working to just use npm start :/

johman10 commented 1 week ago

Hi @iveney, Thanks a lot for your contribution! I think this was a great suggestion so it will be released with the next release (probably still happening this week).