FIX: Don’t raise on some search terms

Currently, when certain search terms are provided, this can lead to
`Search.need_segmenting?` raising an error because it makes `URI#path`
to return `nil` instead of a string.

This patch forces a cast to string so it won’t raise anymore.
This commit is contained in:
Loïc Guitaut
2024-09-19 10:42:48 +02:00
committed by Loïc Guitaut
parent e68748318e
commit fe1098ebac
2 changed files with 9 additions and 1 deletions

View File

@ -228,7 +228,7 @@ class Search
def self.need_segmenting?(data)
return false if data.match?(/\A\d+\z/)
!URI.parse(data).path.start_with?("/")
!URI.parse(data).path.to_s.start_with?("/")
rescue URI::InvalidURIError
true
end