www-redirect 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -0
- data/lib/www-redirect/middleware.rb +1 -1
- data/lib/www-redirect/railtie.rb +5 -3
- data/lib/www-redirect/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 97eec9b46c6adee17ee52e1f37a929065f13afd1
|
4
|
+
data.tar.gz: 8eda2a2454105925c8f6501f4abe120f0f9afcce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ed675f3b06624ba5f1188c5da8218dffa9c362ce916c291a7c31f4a244fcb319507a9649886247f21effa0adde56474e8341ca88b845f285ef42af23a4e8c3ae
|
7
|
+
data.tar.gz: 326d5752db7d59181a7100e43484404c8be9f35ad51c14594064b9a90dac62abe574b74d5d0fdd5008f27b61c4100229cc65c0d249e739966ac3b3d9c79b7b7a
|
data/README.md
CHANGED
@@ -3,6 +3,11 @@ WwwRedirect
|
|
3
3
|
|
4
4
|
Redirect to non www url, so from `www.example.com` to `example.com`
|
5
5
|
|
6
|
+
Rails Compatibility
|
7
|
+
-------
|
8
|
+
WwwRedirect is compatible with rails through railtie module.
|
9
|
+
However using the gem on non-rails apps is also possible.
|
10
|
+
|
6
11
|
Installation
|
7
12
|
-------
|
8
13
|
gem 'www-redirect'
|
@@ -7,7 +7,7 @@ module WwwRedirect
|
|
7
7
|
|
8
8
|
def call(env)
|
9
9
|
request = Rack::Request.new(env)
|
10
|
-
return [301, {"Location" => request.url.sub("//www.", "//")}, []] if request.host.
|
10
|
+
return [301, {"Location" => request.url.sub("//www.", "//")}, []] if request.host.match(%r[^www.])
|
11
11
|
|
12
12
|
@app.call(env)
|
13
13
|
end
|
data/lib/www-redirect/railtie.rb
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
module WwwRedirect
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
if defined?(Rails)
|
4
|
+
class Railtie < Rails::Railtie
|
5
|
+
initializer "www-redirect.configure_rails_initialization" do |app|
|
6
|
+
app.middleware.use 'WwwRedirect::Middleware'
|
7
|
+
end
|
6
8
|
end
|
7
9
|
end
|
8
10
|
|
data/lib/www-redirect/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: www-redirect
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kubenstein
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-08-25 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Redirect to non www url of your page
|
14
14
|
email:
|