Skip to content

Commit

Permalink
fix parsing of robots.txt
Browse files Browse the repository at this point in the history
  • Loading branch information
branch14 committed Jul 23, 2014
1 parent 9401688 commit 70ebb03
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion app/middlewares/enforce_robots_txt.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ def call(env)
private

def robots_txt
@robots_txt ||= File.read(opts[:source]).split.inject([]) do |result, line|
return @robots_txt unless @robots_txt.nil?
lines = File.read(opts[:source]).split("\n")
@robots_txt = lines.inject([]) do |result, line|
case line
when /User-agent:\s*(.+)\s*$/ then result << [$1, []]
when /Disallow:\s*(.+)\s*$/ then result.last.last << $1
Expand Down

0 comments on commit 70ebb03

Please sign in to comment.