rack-locale-root-redirect 0.0.4 → 0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,7 +2,7 @@ require "rack/accept"
2
2
 
3
3
  module Rack
4
4
  class LocaleRootRedirect
5
- VERSION = "0.0.4"
5
+ VERSION = "0.1"
6
6
 
7
7
  def initialize(app, locales = {})
8
8
  @locales = locales
@@ -14,13 +14,13 @@ module Rack
14
14
  def call(env)
15
15
  status, headers, response = @app.call(env)
16
16
 
17
- if env["REQUEST_URI"] == "/"
17
+ if match_data = %r[\A/(?<query_string>\?.*|\Z)].match(env["REQUEST_URI"])
18
18
  language_matcher = env['rack-accept.request'].language
19
19
  language_matcher.first_level_match = true
20
20
  redirect_lang = language_matcher.best_of(@available_locales) || @default_locale
21
21
 
22
22
  status = 302
23
- headers["Location"] = @locales[redirect_lang.to_sym]
23
+ headers["Location"] = @locales[redirect_lang.to_sym] + match_data[:query_string]
24
24
  end
25
25
 
26
26
  [status, headers, response]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-locale-root-redirect
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: '0.1'
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-12-28 00:00:00.000000000 Z
12
+ date: 2013-07-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rack-accept
@@ -62,10 +62,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
62
62
  version: '0'
63
63
  requirements: []
64
64
  rubyforge_project:
65
- rubygems_version: 1.8.24
65
+ rubygems_version: 1.8.23
66
66
  signing_key:
67
67
  specification_version: 3
68
68
  summary: Rack::LocaleRootRedirect uses Rack:Accept to map '/' to a path based on the
69
69
  `Accept-Language` HTTP header.
70
70
  test_files: []
71
- has_rdoc: