add the ability to ignore certain urls that may match

This commit is contained in:
John Bintz 2011-12-01 07:25:02 -05:00
parent aaa701bac9
commit 20ef5cc1f3
3 changed files with 35 additions and 23 deletions

View File

@ -25,7 +25,8 @@ MyApp::Application.configure do
:min_delay => 500,
:max_delay => 10000,
:port => 56789,
:host => 'myhost.cool.wow'
:host => 'myhost.cool.wow',
:ignore => [ %r{dont/modify\.html$} ]
)
end
```

View File

@ -48,6 +48,7 @@ module Rack
else
status, headers, body = @app.call(env)
if !@options[:ignore] || !@options[:ignore].any? { |filter| path[filter] }
case headers['Content-Type']
when %r{text/html}
content_length = 0
@ -78,6 +79,7 @@ module Rack
headers['Content-Length'] = content_length.to_s
end
end
[ status, headers, body ]
end

View File

@ -132,6 +132,15 @@ describe Rack::LiveReload do
body.should include('localhost')
end
end
context 'ignored' do
let(:options) { { :ignore => [ %r{file} ] } }
let(:env) { { 'PATH_INFO' => 'this/file' } }
it 'should have no change' do
body.should_not include('script')
end
end
end
context '/__rack/livereload.js' do