rewritten 0.16.3 → 0.16.4
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 +4 -4
- data/HISTORY.rdoc +4 -0
- data/lib/rack/url.rb +14 -0
- data/lib/rewritten/version.rb +1 -1
- data/test/rack/rewritten_url_test.rb +14 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a254642e07ed0bb8b46f4c9ebe95a152ac94481e
|
4
|
+
data.tar.gz: 52fe0a75b830039b7d2a0b78a05e13c4e902df53
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b7835a4629b4980b5276a0a55a3da1d8017ca7cb117b5619b0c52167413ad14a485e10bab38f737fdc4a6e6b2b5b042959f7ca3a21cfdf8d93b2ce59e0e90e53
|
7
|
+
data.tar.gz: a40d86b684035a29ea2be929d94d071a522ac352a4d0a9dc148c6434d6b55dd75f9df87ebf2f3dfb13b190c52747e3ac5840d60349a3eff670a5eb0bd5542f28
|
data/HISTORY.rdoc
CHANGED
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)
|
data/lib/rewritten/version.rb
CHANGED
@@ -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
|