http-negotiate 0.1.2 → 0.1.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 97e8bcc59dec991c82e9e253b34ab3643ee7b62441b2d890c1988bcd2bd6a941
4
- data.tar.gz: 66a3825c19b6ab786a4b1fdca2cd5fff90d03b91d72aea495576f2e3312c2bb1
3
+ metadata.gz: 5eba28c71dd714d3254c4f9d0922b9c337ac5ec1ef91c353abd276aea7ec58ad
4
+ data.tar.gz: 714671385c02e7977da9adbef08e8cab7cf7665fd146e64613ba18814fbc2922
5
5
  SHA512:
6
- metadata.gz: 89807147d59bfeadcfa20e4228bbd6de119c2bcadcfcf76c204516e20a47c049c8c0a7d736e05265f5f737d10ce8b1c4a49ee7da4719a0c30abe7e62dba57c2c
7
- data.tar.gz: 8f83584309e4a1fb37b46c53b3618bba9a470030414e20d30c8f96bbf09deecc003674fd265262193ea4fecf3053de20927f35fd676a547c46586941e77e8381
6
+ metadata.gz: '085588d4db497e88d80de41198fff309d3ff0babe419803e5b915b150a5717a24b849cca6219593da6e122490b18676c199f793d626ec860d3bafb49011db278'
7
+ data.tar.gz: fc87172adb4cd18ae9ede3e373655cef0c67d20d2f37989d8fb6e5f464f602ed0f333a5a8e63db0b1c1e5ca70da66d13efd98715cd643dc08944b70a96fb53e9
@@ -1,5 +1,5 @@
1
1
  module HTTP
2
2
  module Negotiate
3
- VERSION = '0.1.2'
3
+ VERSION = '0.1.3'
4
4
  end
5
5
  end
@@ -145,24 +145,30 @@ module HTTP::Negotiate
145
145
 
146
146
  # calculate the language quality
147
147
  ql = 1
148
- if accept[:language] and language
149
- ql = 0.001 # initial value is very low but not zero
150
- lang = language.split(/-+/)
151
- (1..lang.length).to_a.reverse.each do |i|
152
- test = lang.slice(0, i).join ?-
153
- if accept[:language][test]
154
- al = accept[:language][test][:q]
155
- if al == 0
156
- ql = 0
157
- break
158
- elsif al > ql
159
- ql = al
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.2
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-08 00:00:00.000000000 Z
11
+ date: 2021-11-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler