Skip to content

Commit

Permalink
Merge branch 'fix/infinitive'
Browse files Browse the repository at this point in the history
  • Loading branch information
learnjin committed Aug 18, 2014
2 parents 978acf4 + 52947e7 commit c363ead
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
5 changes: 4 additions & 1 deletion lib/rewritten.rb
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,8 @@ def get_current_translation(path, tail=nil)
# infinitive for translations only!
def infinitive(some_from)

some_from ||= ''

conjugated = some_from.chomp('/')

to = translate(conjugated)
Expand All @@ -240,7 +242,8 @@ def infinitive(some_from)
infinitive(shorter_path)
else
conjugated = get_current_translation(to) if to
conjugated.split('?')[0].chomp('/')
conjugated = conjugated.split('?')[0] || ''
conjugated.chomp('/')
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/rewritten/version.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Rewritten
VERSION = "0.14.1"
VERSION = "0.14.2"
end

4 changes: 4 additions & 0 deletions test/rewritten_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@

describe 'get_infinitive (always from conjugated for -> for)' do

it 'must work with nil' do
Rewritten.infinitive(nil).must_equal ''
end

it 'must remove query parameters from non translatable foreign path' do
Rewritten.infinitive('/no/translation').must_equal '/no/translation'
Rewritten.infinitive('/no/translation/').must_equal '/no/translation'
Expand Down

0 comments on commit c363ead

Please sign in to comment.