Skip to content

Commit

Permalink
Fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielHeath committed Mar 14, 2019
1 parent 2f8cf73 commit 1e15706
Showing 1 changed file with 23 additions and 24 deletions.
47 changes: 23 additions & 24 deletions lib/html-proofer/middleware.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,41 +14,41 @@ def self.options
}
end

def initialize app
def initialize(app)
@app = app
end

HTML_SIGNATURE = [
"<!DOCTYPE HTML",
"<HTML",
"<HEAD",
"<SCRIPT",
"<IFRAME",
"<H1",
"<DIV",
"<FONT",
"<TABLE",
"<A",
"<STYLE",
"<TITLE",
"<B",
"<BODY",
"<BR",
"<P",
"<!--"
'<!DOCTYPE HTML',
'<HTML',
'<HEAD',
'<SCRIPT',
'<IFRAME',
'<H1',
'<DIV',
'<FONT',
'<TABLE',
'<A',
'<STYLE',
'<TITLE',
'<B',
'<BODY',
'<BR',
'<P',
'<!--'
]

def call env
def call(env)
result = @app.call(env)
return result if env["REQUEST_METHOD"] != "GET"
return result if env["QUERY_STRING"] =~ /SKIP_VALIDATION/
return result if env['REQUEST_METHOD'] != 'GET'
return result if env['QUERY_STRING'] =~ /SKIP_VALIDATION/
return result if result.first != 200

# [@status, @headers, @response]
body = []
result.last.each {|e| body << e}
result.last.each { |e| body << e }
html = body.join('').lstrip
if HTML_SIGNATURE.any? {|sig| html.downcase.starts_with? sig.downcase}
if HTML_SIGNATURE.any? { |sig| html.downcase.starts_with? sig.downcase }
parsed = HTMLProofer::Runner.new(
'response',
Middleware.options
Expand All @@ -64,4 +64,3 @@ def call env
end
end
end

0 comments on commit 1e15706

Please sign in to comment.