mirror of
https://github.com/nishiki/manage-password.git
synced 2024-11-27 07:33:05 +00:00
Now the search isn't sensible to case
This commit is contained in:
parent
6e3d21e81d
commit
e2362c020a
1 changed files with 12 additions and 1 deletions
13
lib/MPW.rb
13
lib/MPW.rb
|
@ -144,8 +144,19 @@ class MPW
|
||||||
# @rtrn: a list with the resultat of the search
|
# @rtrn: a list with the resultat of the search
|
||||||
def search(search, group=nil, protocol=nil)
|
def search(search, group=nil, protocol=nil)
|
||||||
result = Array.new()
|
result = Array.new()
|
||||||
|
|
||||||
|
if !search.nil?
|
||||||
|
search = search.downcase
|
||||||
|
end
|
||||||
|
search = search.force_encoding('ASCII-8BIT')
|
||||||
|
|
||||||
@data.each do |row|
|
@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]))
|
if (protocol.nil? || protocol.eql?(row[PROTOCOL])) && (group.nil? || group.eql?(row[GROUP]))
|
||||||
result.push(row)
|
result.push(row)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue