Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #109 from troynt/master

Subpath shouldn't match partial URL segments. e.g. /resources/1 vs /resources_group/1
  • Loading branch information...
commit 79ea081ac772744362e925b8a0034bc6adf10c51 2 parents 7f659a7 + d5e5418
@andi andi authored
View
2  lib/simple_navigation/core/item.rb
@@ -89,7 +89,7 @@ def selected_by_condition?
when Proc
highlights_on.call
when :subpath
- !!(SimpleNavigation.request_uri =~ /^#{Regexp.escape url_without_anchor}/)
+ !!(SimpleNavigation.request_uri =~ /^#{Regexp.escape url_without_anchor}(\/|$|\?)/i)
else
raise ArgumentError, ':highlights_on must be a Regexp, Proc or :subpath'
end
View
6 spec/lib/simple_navigation/core/item_spec.rb
@@ -397,6 +397,12 @@
end
it {@item.send(:selected_by_condition?).should be_true}
end
+ context 'we are in a route that has a similar name' do
+ before(:each) do
+ SimpleNavigation.stub!(:request_uri => '/resources_group/id')
+ end
+ it {@item.send(:selected_by_condition?).should be_false}
+ end
context 'we are in a route not beginning with this item path' do
before(:each) do
SimpleNavigation.stub!(:request_uri => '/another_resource/id')
Please sign in to comment.
Something went wrong with that request. Please try again.