rewritten 0.13.0 → 0.13.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f04c056a99d6a3acda82865046870011d45869e6
4
- data.tar.gz: 2e1e1d2551c2303756f1ea6c4f6dc29dd0e74614
3
+ metadata.gz: ec0125862e538037c12d709768eda65cf08e3cb6
4
+ data.tar.gz: d02def0f2df7280603224f60e4c709844c1b56fe
5
5
  SHA512:
6
- metadata.gz: 5d86aca2260d03f7855526b6a5bf8bcafab65739318900eb79dd7f2a6a0eabba67b5aca00b002914c69059d27d6bd15252ddff210f6cd47dbc3e9fe5b6a91ddf
7
- data.tar.gz: 1b3f8c5c56a42fe6e62237bfd5abc96df833b61cf1054e10e1e987d11b5a1d8a780fc660632ad4619971d0b17880d0b71b8f5efa93f5ba3a9b59d93801985d7b
6
+ metadata.gz: c02e89f98798a7e84e2bab137f3ef0d54c99376928adaac861c398434df0c18704155ca4b7bd4a9860df4bd169443b08a9b585d6ccef682148c6ed8306a84012
7
+ data.tar.gz: a4d30fd8357c5ff63cac5de1592d52c3cc0bf95450d1da298ed68b12a602de080cb36206f6dbd7577f04975d0cb233966825dc6387454f3dcb53b55dd1f1c6d4
data/HISTORY.rdoc CHANGED
@@ -1,3 +1,6 @@
1
+ == 0.13.0
2
+ * Find translations even for absolute urls and urls with query parameters
3
+
1
4
  == 0.12.0
2
5
 
3
6
  * Add the Rewritten::Document module that adds virtual attribute accessors (rewritten_url) to a rails model
@@ -1,4 +1,4 @@
1
1
  module Rewritten
2
- VERSION = "0.13.0"
2
+ VERSION = "0.13.1"
3
3
  end
4
4
 
data/lib/rewritten.rb CHANGED
@@ -196,11 +196,10 @@ module Rewritten
196
196
  translation = Rewritten.z_range("to:#{uri.path}", -1)
197
197
  end
198
198
 
199
- translation = path unless translation
200
-
199
+ # return path as is if no translation found
200
+ return path unless translation
201
201
 
202
202
  translated_uri = URI.parse(translation)
203
-
204
203
  uri.path = translated_uri.path
205
204
  uri.query = [translated_uri.query, uri.query].compact.join('&')
206
205
  uri.query = nil if uri.query == ''
@@ -25,6 +25,10 @@ describe Rewritten do
25
25
  Rewritten.get_current_translation('/to_without_params?some=param').must_equal '/from_without_params?some=param'
26
26
  end
27
27
 
28
+ it "must not add parameters twice if no translation is found" do
29
+ Rewritten.get_current_translation('/no/translation?some=param').must_equal '/no/translation?some=param'
30
+ end
31
+
28
32
  it "must translate if protocol and host are given" do
29
33
  Rewritten.add_translation('/from_without_params', '/to_without_params')
30
34
  Rewritten.get_current_translation('http://localhost:3000/to_without_params').must_equal 'http://localhost:3000/from_without_params'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rewritten
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.0
4
+ version: 0.13.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kai Rubarth