krisk / fuse-swift

A lightweight fuzzy-search library, with zero dependencies
MIT License
934 stars 112 forks source link

String Comparison Crash #18

Closed saru2020 closed 5 years ago

saru2020 commented 5 years ago

Hi,

Is there any reason why the below line of string comparison would lead to a crash?

    let result = fuse.search("Rancheras 2016 Borracho de Amor  Por Tu Maldito Amor  Hermoso Carino  Se Va Muriendo Mi Alma  Por un Amor", in: "Borracho De Amor")
fuse - comparison fuse - crash

Any help would be appreciated. Thanks!

krisk commented 5 years ago

You have the arguments the other way around.

Your pattern is the first argument, and the string you are searching in is your second.

See here for reference.

adamcichy commented 5 years ago

@krisk The same bug happens randomly for me when the pattern is longer than the string (which happens often in my case but works fine most of the time). Should I prevent such usecase in my code? O is there going to be a release that will handle this case?