Skip to content

Commit

Permalink
Formatted rules.cr correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
jo1gi committed Apr 9, 2021
1 parent d10667f commit 2840e38
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions src/rules.cr
Expand Up @@ -20,18 +20,17 @@ module Rules
return false
end


# Tests if a set of rules match the url
def test_command(url : String, option) : Bool
if !option["command"]?
return false
end
@@rules.each do |name, test|
if option[name]?
if make_regex_test(url, test, option[name].as_s)
next
end
return false
if make_regex_test(url, test, option[name].as_s)
next
end
return false
end
end
return true
Expand All @@ -41,13 +40,13 @@ module Rules
def find_command(url : String, config)
config.as_a.each do |c|
if test_command(url, c)
if c["subrules"]
subrules = find_command(url, c["subrules"])
if subrules
return subrules
end
end
return c["command"].as_s.not_nil!
if c["subrules"]
subrules = find_command(url, c["subrules"])
if subrules
return subrules
end
end
return c["command"].as_s.not_nil!
end
end
end
Expand Down

0 comments on commit 2840e38

Please sign in to comment.