rack-no-www 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2010 Logicaltext
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,5 @@
1
+ module Rack
2
+ class NoWWW
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,26 @@
1
+ require 'rack/no-www/version.rb'
2
+
3
+ module Rack
4
+ class NoWWW
5
+
6
+ STARTS_WITH_WWW = /^www\./i
7
+
8
+ def initialize(app)
9
+ @app = app
10
+ end
11
+
12
+ def call(env)
13
+ if env['HTTP_HOST'] =~ STARTS_WITH_WWW
14
+ [301, no_www_request(env), ["Moved Permanently\n"]]
15
+ else
16
+ @app.call(env)
17
+ end
18
+ end
19
+
20
+ private
21
+ def no_www_request(env)
22
+ { 'Location' => Rack::Request.new(env).url.sub(/www\./i, '') }
23
+ end
24
+
25
+ end
26
+ end
@@ -0,0 +1 @@
1
+ require 'rack/no-www'
metadata ADDED
@@ -0,0 +1,73 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rack-no-www
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - logicaltext
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-06-22 00:00:00 -04:00
19
+ default_executable:
20
+ dependencies: []
21
+
22
+ description: Rack middleware for redirecting 'www' requests, based on the original idea by trevorturk (http://trevorturk.com/2009/11/05/no-www-rack-middleware/).
23
+ email:
24
+ - logicaltext@logicaltext.com
25
+ executables: []
26
+
27
+ extensions: []
28
+
29
+ extra_rdoc_files: []
30
+
31
+ files:
32
+ - lib/rack/no-www/version.rb
33
+ - lib/rack/no-www.rb
34
+ - lib/rack-no-www.rb
35
+ - LICENSE
36
+ has_rdoc: true
37
+ homepage: http://github.com/logicaltext/rack-no-www
38
+ licenses: []
39
+
40
+ post_install_message:
41
+ rdoc_options: []
42
+
43
+ require_paths:
44
+ - lib
45
+ required_ruby_version: !ruby/object:Gem::Requirement
46
+ none: false
47
+ requirements:
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ hash: 3
51
+ segments:
52
+ - 0
53
+ version: "0"
54
+ required_rubygems_version: !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ hash: 23
60
+ segments:
61
+ - 1
62
+ - 3
63
+ - 6
64
+ version: 1.3.6
65
+ requirements: []
66
+
67
+ rubyforge_project: rack-no-www
68
+ rubygems_version: 1.3.7
69
+ signing_key:
70
+ specification_version: 3
71
+ summary: Rack middleware for redirecting 'www' requests
72
+ test_files: []
73
+