class Rack::Nojs
Constants
- VERSION
Public Class Methods
new(app)
click to toggle source
# File lib/rack/nojs.rb, line 10 def initialize(app) @app = app end
Public Instance Methods
_call(env)
click to toggle source
# File lib/rack/nojs.rb, line 16 def _call(env) @env = env req = Rack::Request.new(env) @status, @headers, @body = @app.call(env) return [@status, @headers, @body] if !html? || !req.mobile? response = Rack::Response.new([], @status, @headers) @body.each { |fragment| response.write inject(fragment) } @body.close if @body.respond_to?(:close) response.finish end
call(env)
click to toggle source
# File lib/rack/nojs.rb, line 14 def call(env); dup._call(env); end
Private Instance Methods
html?()
click to toggle source
# File lib/rack/nojs.rb, line 30 def html?; @headers['Content-Type'] =~ /html/; end
inject(response)
click to toggle source
# File lib/rack/nojs.rb, line 32 def inject(response) response.gsub(/<script type="text\/javascript"[\w\W]*?<\/script>/, '') end