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.
@@ -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 = "#{env['rack.url_scheme']}://#{prefix}.#{chunk}.#{suffix}"
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 /']]
@@ -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.2"
11
+ gem.version = "0.0.3"
12
12
 
13
13
  gem.add_development_dependency 'rspec'
14
14
  gem.add_development_dependency 'rake-test'
@@ -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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack_slashless
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: