Skip to content
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...
2 parents 7f659a7 + d5e5418 commit 79ea081ac772744362e925b8a0034bc6adf10c51 @andi andi committed
Showing with 7 additions and 1 deletion.
  1. +1 −1 lib/simple_navigation/core/item.rb
  2. +6 −0 spec/lib/simple_navigation/core/item_spec.rb
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')

0 comments on commit 79ea081

Please sign in to comment.
Something went wrong with that request. Please try again.