Sha256: e4703832fcdbbc12618ec60f20b00f29b93e956a1c7550396c5d7e6e4f0107a8

Contents?: true

Size: 641 Bytes

Versions: 8

Compression:

Stored size: 641 Bytes

Contents

require 'rack/request'
require 'rack/response'

module Roger
  module Rack
    class HtmlValidator
      def initialize(app)
        @app = app
      end
      
      def call(env)
        resp = @app.call(env)
        if resp[1]["Content-Type"].to_s.include?("html")
          str = ""
          resp[2].each{|c| str << c}
          validator = W3CValidator.new(str)
          validator.validate!
          if !validator.valid
            env["rack.errors"].puts "Validation failed on #{env["PATH_INFO"]}: (errors: #{validator.errors}, warnings: #{validator.warnings})"
          end
        end
        resp
      end    
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
roger-0.12.5 lib/roger/rack/html_validator.rb
roger-0.12.4 lib/roger/rack/html_validator.rb
roger-0.12.3 lib/roger/rack/html_validator.rb
roger-0.12.2 lib/roger/rack/html_validator.rb
roger-0.12.1 lib/roger/rack/html_validator.rb
roger-0.12.0 lib/roger/rack/html_validator.rb
roger-0.11.0 lib/roger/rack/html_validator.rb
roger-0.10.0 lib/roger/rack/html_validator.rb