rewritten 0.16.3 → 0.16.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e4c5d5f3b82a279cbf7537015998ea7bb2d953d1
4
- data.tar.gz: c9d424c04a59af197e4809be37512e9b8099dc76
3
+ metadata.gz: a254642e07ed0bb8b46f4c9ebe95a152ac94481e
4
+ data.tar.gz: 52fe0a75b830039b7d2a0b78a05e13c4e902df53
5
5
  SHA512:
6
- metadata.gz: ef7b3bb9e140229bc5d7bebe36624f80d9b65a98eb100b9044120f16989a0571af71478610263a29da7d04ccdf1a4659a5b4bd7f7ebec33ee6ef5a9ea81971df
7
- data.tar.gz: de967382e05689032659860628760ff75debcd1d9fbee7bc9da42b6c95119ff0681c8d09c97a31fe7b0c58edbd8d083718a3c508a107b1d93114c8b58c384882
6
+ metadata.gz: b7835a4629b4980b5276a0a55a3da1d8017ca7cb117b5619b0c52167413ad14a485e10bab38f737fdc4a6e6b2b5b042959f7ca3a21cfdf8d93b2ce59e0e90e53
7
+ data.tar.gz: a40d86b684035a29ea2be929d94d071a522ac352a4d0a9dc148c6434d6b55dd75f9df87ebf2f3dfb13b190c52747e3ac5840d60349a3eff670a5eb0bd5542f28
data/HISTORY.rdoc CHANGED
@@ -1,3 +1,7 @@
1
+ == 0.16.4
2
+
3
+ * Fix trailing slash redirect
4
+
1
5
  == 0.16.3
2
6
 
3
7
  * Fix malformed path_info that contained query_string
data/lib/rack/url.rb CHANGED
@@ -47,6 +47,20 @@ module Rack
47
47
  current_path_with_query = current_path
48
48
  current_path = current_path.split('?')[0]
49
49
 
50
+ if current_path.size + 1 == req.path_info.size and current_path == req.path_info.chomp('/')
51
+ r = Rack::Response.new
52
+
53
+ new_path = env['rack.url_scheme'].dup
54
+ new_path << '://'
55
+ new_path << env['HTTP_HOST'].dup.sub(/^#{subdomain.chomp(':')}\./, '')
56
+ new_path << current_path
57
+ new_path << ::Rewritten.appendix(path) unless backwards
58
+ new_path << '?' << env['QUERY_STRING'] unless (env['QUERY_STRING'] || '').empty?
59
+
60
+ r.redirect(new_path, 301)
61
+ return r.finish
62
+ end
63
+
50
64
  if (req.fullpath == current_path_with_query || current_path == req.path_info) || (::Rewritten.base_from(req.path_info) == current_path) || ::Rewritten.flag?(path, 'L')
51
65
  # if this is the current path, rewrite path and parameters
52
66
  tpath, tparams = split_to_path_params(to)
@@ -1,3 +1,3 @@
1
1
  module Rewritten
2
- VERSION = '0.16.3'
2
+ VERSION = '0.16.4'
3
3
  end
@@ -134,7 +134,20 @@ describe Rack::Rewritten::Url do
134
134
  end
135
135
 
136
136
  describe '/ behavior' do
137
- it 'must 301 redirect paths with / in the end to their chomped version' do
137
+ it 'must 301 redirect current paths with / in the end to their chomped version' do
138
+ ret = @rack.call request_url('/foo/baz/')
139
+ @app.verify
140
+ ret[0].must_equal 301
141
+ ret[1]['Location'].must_equal 'http://www.example.org/foo/baz'
142
+ end
143
+
144
+ it 'wont 301 redirect /' do
145
+ @app.expect :call, [200, { 'Content-Type' => 'text/plain' }, ['']], [Hash]
146
+ ret = @rack.call request_url('/')
147
+ @app.verify
148
+ end
149
+
150
+ it 'must 301 redirect paths with / in the end to their current chomped version' do
138
151
  ret = @rack.call request_url('/foo/bar/')
139
152
  @app.verify
140
153
  ret[0].must_equal 301
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.16.3
4
+ version: 0.16.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kai Rubarth