rack_slashless 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/rack_slashless.rb +3 -1
- data/rack_slashless.gemspec +1 -1
- data/spec/rack_slashless_spec.rb +10 -0
- metadata +1 -1
data/lib/rack_slashless.rb
CHANGED
@@ -10,7 +10,9 @@ module Rack
|
|
10
10
|
parts = env['SERVER_NAME'].split('.')
|
11
11
|
suffix, chunk, prefix = parts.pop, parts.pop, parts.pop
|
12
12
|
|
13
|
-
destination
|
13
|
+
destination = "#{env['rack.url_scheme']}://"
|
14
|
+
destination << "#{prefix}." if prefix
|
15
|
+
destination << "#{chunk}.#{suffix}"
|
14
16
|
destination << "#{env['PATH_INFO']}"[0..-2]
|
15
17
|
|
16
18
|
[301, {'Location' => destination}, ['Redirecting to the same url but with the ending /']]
|
data/rack_slashless.gemspec
CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |gem|
|
|
8
8
|
gem.test_files = `git ls-files -- spec/*`.split("\n")
|
9
9
|
gem.name = "rack_slashless"
|
10
10
|
gem.require_paths = ["lib"]
|
11
|
-
gem.version = "0.0.
|
11
|
+
gem.version = "0.0.3"
|
12
12
|
|
13
13
|
gem.add_development_dependency 'rspec'
|
14
14
|
gem.add_development_dependency 'rake-test'
|
data/spec/rack_slashless_spec.rb
CHANGED
@@ -15,6 +15,16 @@ describe Rack::Slashless do
|
|
15
15
|
last_response.status.should == 301
|
16
16
|
last_response['Location'].should eql('http://www.example.org')
|
17
17
|
end
|
18
|
+
|
19
|
+
context "without a subdomain" do
|
20
|
+
it "should redirect to server name" do
|
21
|
+
get '/', {}, {'SERVER_NAME' => 'example.org'}
|
22
|
+
|
23
|
+
last_response.status.should == 301
|
24
|
+
last_response['Location'].should eql('http://example.org')
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
18
28
|
end
|
19
29
|
|
20
30
|
describe "/blog/" do
|