rack-locale-root-redirect 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md CHANGED
@@ -40,3 +40,17 @@ end
40
40
 
41
41
  run MyApp
42
42
  ```
43
+
44
+ Then, test it:
45
+
46
+ ```shell
47
+ $ rackup &
48
+
49
+ $ curl -sI "http://0.0.0.0:9292" -H "Accept-Language: fr;q=1, en;q=0.8" | grep "301\|Location"
50
+ HTTP/1.1 301 Moved Permanently
51
+ Location: /fr
52
+
53
+ $ curl -sI "http://0.0.0.0:9292" -H "Accept-Language: fr;q=0.4, en;q=0.8" | grep "301\|Location"
54
+ HTTP/1.1 301 Moved Permanently
55
+ Location: /en
56
+ ```
@@ -2,7 +2,7 @@ require "rack/accept"
2
2
 
3
3
  module Rack
4
4
  class LocaleRootRedirect
5
- VERSION = "0.0.1"
5
+ VERSION = "0.0.2"
6
6
 
7
7
  def initialize(app, locales = {})
8
8
  @locales = locales
@@ -19,8 +19,8 @@ module Rack
19
19
  language_matcher.first_level_match = true
20
20
  redirect_lang = language_matcher.best_of(@available_locales) || @default_locale
21
21
 
22
- status = 301
23
- headers["Location"] = @locales[redirect_lang.to_sym]
22
+ status = 302
23
+ headers["Location"] = "#{env["HTTP_HOST"]}#{@locales[redirect_lang.to_sym]}"
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.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: