Fixed ignore to work with full URI

This commit is contained in:
Anton Orel 2015-08-02 13:59:27 +03:00
parent 41bdc64bcb
commit 78379f041f
2 changed files with 9 additions and 9 deletions

View File

@ -28,8 +28,9 @@ module Rack
end end
def ignored? def ignored?
path = @env['QUERY_STRING'].empty? ? @env['PATH_INFO'] : "#{@env['PATH_INFO']}?#{@env['QUERY_STRING']}" @options[:ignore] and @options[:ignore].any? do |filter|
@options[:ignore] and @options[:ignore].any? { |filter| path[filter] } @env['REQUEST_URI'][filter]
end
end end
def bad_browser? def bad_browser?

View File

@ -22,13 +22,13 @@ describe Rack::LiveReload::ProcessingSkipAnalyzer do
let(:options) { { :ignore => [ %r{file} ] } } let(:options) { { :ignore => [ %r{file} ] } }
context 'path contains ignore pattern' do context 'path contains ignore pattern' do
let(:env) { { 'PATH_INFO' => '/this/file', 'QUERY_STRING' => '' } } let(:env) { { 'REQUEST_URI' => '/this/file', 'QUERY_STRING' => '' } }
it { should be_ignored } it { should be_ignored }
end end
context 'root path' do context 'root path' do
let(:env) { { 'PATH_INFO' => '/', 'QUERY_STRING' => '' } } let(:env) { { 'REQUEST_URI' => '/', 'QUERY_STRING' => '' } }
it { should_not be_ignored } it { should_not be_ignored }
end end
@ -55,22 +55,21 @@ describe Rack::LiveReload::ProcessingSkipAnalyzer do
end end
describe '#ignored?' do describe '#ignored?' do
let(:path_info) { 'path info' } let(:request_uri) { 'request_path?query_string' }
let(:query_string) { 'query_string' } let(:env) { { 'REQUEST_URI' => request_uri } }
let(:env) { { 'PATH_INFO' => path_info, 'QUERY_STRING' => query_string } }
context 'no ignore set' do context 'no ignore set' do
it { should_not be_ignored } it { should_not be_ignored }
end end
context 'ignore set' do context 'ignore set' do
let(:options) { { :ignore => [ %r{#{path_info}} ] } } let(:options) { { :ignore => [ /request_path/ ] } }
it { should be_ignored } it { should be_ignored }
end end
context 'ignore set including query_string' do context 'ignore set including query_string' do
let(:options) { { :ignore => [ %r{#{path_info}\?#{query_string}} ] } } let(:options) { { :ignore => [ /query_string/ ] } }
it { should be_ignored } it { should be_ignored }
end end