From 64449acbc90c23adc36cdb202398cc7af6f91677 Mon Sep 17 00:00:00 2001 From: Robert Coleman Date: Tue, 26 Nov 2013 12:48:21 +1300 Subject: [PATCH] parse fullpath for ignore --- lib/rack/livereload/processing_skip_analyzer.rb | 3 ++- .../livereload/processing_skip_analyzer_spec.rb | 13 ++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/rack/livereload/processing_skip_analyzer.rb b/lib/rack/livereload/processing_skip_analyzer.rb index ba6ae63..ec2b654 100644 --- a/lib/rack/livereload/processing_skip_analyzer.rb +++ b/lib/rack/livereload/processing_skip_analyzer.rb @@ -28,7 +28,8 @@ module Rack end def ignored? - @options[:ignore] and @options[:ignore].any? { |filter| @env['PATH_INFO'][filter] } + path = @env['QUERY_STRING'].empty? ? @env['PATH_INFO'] : "#{@env['PATH_INFO']}?#{@env['QUERY_STRING']}" + @options[:ignore] and @options[:ignore].any? { |filter| path[filter] } end def bad_browser? diff --git a/spec/rack/livereload/processing_skip_analyzer_spec.rb b/spec/rack/livereload/processing_skip_analyzer_spec.rb index e1c856e..600e386 100644 --- a/spec/rack/livereload/processing_skip_analyzer_spec.rb +++ b/spec/rack/livereload/processing_skip_analyzer_spec.rb @@ -22,13 +22,13 @@ describe Rack::LiveReload::ProcessingSkipAnalyzer do let(:options) { { :ignore => [ %r{file} ] } } context 'path contains ignore pattern' do - let(:env) { { 'PATH_INFO' => '/this/file' } } + let(:env) { { 'PATH_INFO' => '/this/file', 'QUERY_STRING' => '' } } it { should be_ignored } end context 'root path' do - let(:env) { { 'PATH_INFO' => '/' } } + let(:env) { { 'PATH_INFO' => '/', 'QUERY_STRING' => '' } } it { should_not be_ignored } end @@ -56,7 +56,8 @@ describe Rack::LiveReload::ProcessingSkipAnalyzer do describe '#ignored?' do let(:path_info) { 'path info' } - let(:env) { { 'PATH_INFO' => path_info } } + let(:query_string) { 'query_string' } + let(:env) { { 'PATH_INFO' => path_info, 'QUERY_STRING' => query_string } } context 'no ignore set' do it { should_not be_ignored } @@ -67,6 +68,12 @@ describe Rack::LiveReload::ProcessingSkipAnalyzer do it { should be_ignored } end + + context 'ignore set including query_string' do + let(:options) { { :ignore => [ %r{#{path_info}\?#{query_string}} ] } } + + it { should be_ignored } + end end describe '#bad_browser?' do