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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0decf2ff52dd2481a0eabb8a6b2e0ef71f6ec7bf
4
- data.tar.gz: be507d45bd23e349c9099361dea3fd24f173c16d
3
+ metadata.gz: 97eec9b46c6adee17ee52e1f37a929065f13afd1
4
+ data.tar.gz: 8eda2a2454105925c8f6501f4abe120f0f9afcce
5
5
  SHA512:
6
- metadata.gz: ce0cfc6fedde2403211efdb4f4cf8dbd0999c5db6a0bce2abdebeca477d427a4893701ef4940682222dd4b3e851776c0f93abab52c949eed641f63f22c85063c
7
- data.tar.gz: d1741376bc4a34fe52a5d7a2cb14cb860ea5815e6a5b6323e7bcc1502348ecf922eff43c4bc467a933bc582568e9f3305d8082fe5714356584bd48076b8e5b7e
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.starts_with?("www.")
10
+ return [301, {"Location" => request.url.sub("//www.", "//")}, []] if request.host.match(%r[^www.])
11
11
 
12
12
  @app.call(env)
13
13
  end
@@ -1,8 +1,10 @@
1
1
  module WwwRedirect
2
2
 
3
- class Railtie < Rails::Railtie
4
- initializer "www-redirect.configure_rails_initialization" do |app|
5
- app.middleware.use 'WwwRedirect::Middleware'
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
 
@@ -1,3 +1,3 @@
1
1
  module WwwRedirect
2
- VERSION = '0.0.2'
2
+ VERSION = '0.0.3'
3
3
  end
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.2
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-07-10 00:00:00.000000000 Z
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: