Skip to content
This repository has been archived by the owner on Jul 6, 2021. It is now read-only.

Fixed ignore to work with full URI #68

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions lib/rack/livereload/processing_skip_analyzer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ def inline?
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?
Expand Down
13 changes: 6 additions & 7 deletions spec/rack/livereload/processing_skip_analyzer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@
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
Expand All @@ -55,22 +55,21 @@
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
Expand Down