http-negotiate 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/http/negotiate/version.rb +1 -1
- data/lib/http/negotiate.rb +21 -15
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5eba28c71dd714d3254c4f9d0922b9c337ac5ec1ef91c353abd276aea7ec58ad
|
4
|
+
data.tar.gz: 714671385c02e7977da9adbef08e8cab7cf7665fd146e64613ba18814fbc2922
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '085588d4db497e88d80de41198fff309d3ff0babe419803e5b915b150a5717a24b849cca6219593da6e122490b18676c199f793d626ec860d3bafb49011db278'
|
7
|
+
data.tar.gz: fc87172adb4cd18ae9ede3e373655cef0c67d20d2f37989d8fb6e5f464f602ed0f333a5a8e63db0b1c1e5ca70da66d13efd98715cd643dc08944b70a96fb53e9
|
data/lib/http/negotiate.rb
CHANGED
@@ -145,24 +145,30 @@ module HTTP::Negotiate
|
|
145
145
|
|
146
146
|
# calculate the language quality
|
147
147
|
ql = 1
|
148
|
-
if accept[:language]
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
148
|
+
if accept[:language]
|
149
|
+
if language
|
150
|
+
ql = 0.001 # initial value is very low but not zero
|
151
|
+
lang = language.split(/-+/)
|
152
|
+
(0..lang.length).to_a.reverse.each do |i|
|
153
|
+
# apparently there is no wildcard for accept-language? no
|
154
|
+
# wait there is: rfc4647 $2.1 via rfc7231 $5.3.5
|
155
|
+
test = i > 0 ? lang.slice(0, i).join(?-) : ?*
|
156
|
+
if accept[:language][test]
|
157
|
+
al = accept[:language][test][:q]
|
158
|
+
# *;q=0 will override
|
159
|
+
if al == 0 and test != ?*
|
160
|
+
ql = 0
|
161
|
+
break
|
162
|
+
elsif al > ql
|
163
|
+
ql = al
|
164
|
+
end
|
160
165
|
end
|
161
166
|
end
|
167
|
+
elsif any_lang
|
168
|
+
# XXX not sure if language-less variants in the same pool
|
169
|
+
# with language-y ones
|
170
|
+
ql = 0.5
|
162
171
|
end
|
163
|
-
# apparently there is no wildcard for accept-language?
|
164
|
-
elsif accept[:language] and any_lang
|
165
|
-
ql = 0.5
|
166
172
|
end
|
167
173
|
|
168
174
|
# calculate the type quality
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: http-negotiate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dorian Taylor
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-11-
|
11
|
+
date: 2021-11-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|