1
0
Fork 0
mirror of https://github.com/nishiki/manage-password.git synced 2024-11-23 13:57:52 +00:00

Now the search isn't sensible to case

This commit is contained in:
nishiki 2013-12-01 10:03:52 +01:00
parent 6e3d21e81d
commit e2362c020a

View file

@ -144,8 +144,19 @@ class MPW
# @rtrn: a list with the resultat of the search
def search(search, group=nil, protocol=nil)
result = Array.new()
if !search.nil?
search = search.downcase
end
search = search.force_encoding('ASCII-8BIT')
@data.each do |row|
if row[NAME] =~ /^.*#{search}.*$/ || row[SERVER] =~ /^.*#{search}.*$/ || row[COMMENT] =~ /^.*#{search}.*$/
name = row[NAME].downcase
server = row[SERVER].downcase
row[COMMENT].nil? ? (comment = nil) : (comment = row[COMMENT].downcase)
if name =~ /^.*#{search}.*$/ || server =~ /^.*#{search}.*$/ || comment =~ /^.*#{search}.*$/
if (protocol.nil? || protocol.eql?(row[PROTOCOL])) && (group.nil? || group.eql?(row[GROUP]))
result.push(row)
end