From 78379f041feccc99f2b84ddbfe8a3cfb4ede59d7 Mon Sep 17 00:00:00 2001 From: Anton Orel Date: Sun, 2 Aug 2015 13:59:27 +0300 Subject: [PATCH] Fixed ignore to work with full URI --- lib/rack/livereload/processing_skip_analyzer.rb | 5 +++-- .../livereload/processing_skip_analyzer_spec.rb | 13 ++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/rack/livereload/processing_skip_analyzer.rb b/lib/rack/livereload/processing_skip_analyzer.rb index ec2b654..a784730 100644 --- a/lib/rack/livereload/processing_skip_analyzer.rb +++ b/lib/rack/livereload/processing_skip_analyzer.rb @@ -28,8 +28,9 @@ module Rack end def ignored? - path = @env['QUERY_STRING'].empty? ? @env['PATH_INFO'] : "#{@env['PATH_INFO']}?#{@env['QUERY_STRING']}" - @options[:ignore] and @options[:ignore].any? { |filter| path[filter] } + @options[:ignore] and @options[:ignore].any? do |filter| + @env['REQUEST_URI'][filter] + end 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 35c19e4..1c77815 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', 'QUERY_STRING' => '' } } + let(:env) { { 'REQUEST_URI' => '/this/file', 'QUERY_STRING' => '' } } it { should be_ignored } end context 'root path' do - let(:env) { { 'PATH_INFO' => '/', 'QUERY_STRING' => '' } } + let(:env) { { 'REQUEST_URI' => '/', 'QUERY_STRING' => '' } } it { should_not be_ignored } end @@ -55,22 +55,21 @@ describe Rack::LiveReload::ProcessingSkipAnalyzer do end describe '#ignored?' do - let(:path_info) { 'path info' } - let(:query_string) { 'query_string' } - let(:env) { { 'PATH_INFO' => path_info, 'QUERY_STRING' => query_string } } + let(:request_uri) { 'request_path?query_string' } + let(:env) { { 'REQUEST_URI' => request_uri } } context 'no ignore set' do it { should_not be_ignored } end context 'ignore set' do - let(:options) { { :ignore => [ %r{#{path_info}} ] } } + let(:options) { { :ignore => [ /request_path/ ] } } it { should be_ignored } end context 'ignore set including query_string' do - let(:options) { { :ignore => [ %r{#{path_info}\?#{query_string}} ] } } + let(:options) { { :ignore => [ /query_string/ ] } } it { should be_ignored } end -- 2.45.2