kdl 1.0.1 → 1.0.2

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
  SHA256:
3
- metadata.gz: e6560ca3f6df5d91a1a93832f8e5989f16d7e2ee100fa784dcc932e755425008
4
- data.tar.gz: 76a907c6df892adf81898b03b204259284d08c43c4c9b2faff628d82d62c620d
3
+ metadata.gz: c7fd58e017395f4ce4c67e04d8c4324c27bfe816926a41ebf0a813231cbe3eaf
4
+ data.tar.gz: 5ad57dac159e4fabe083f209cf0d0bb07735ed533859da539b0c0796b2d3dc70
5
5
  SHA512:
6
- metadata.gz: 05bff4830aa073df4e14ea87d9eb947ef83009afb5fc2e39ead76d54efe53836e9025e020b4d4a9cd139d52fd1e45bde55005d999ad4f1c2afccfc74d10f5a45
7
- data.tar.gz: 7bea0334e44f33d2022ed2dfc9b59815ba0d380d04d79763958192b4e4146afe622d2e134208899a629f7638528227e50614476076f4e5de620510d8cc7d8e7f
6
+ metadata.gz: 5c84ac4702188843e47041424d50e35ed19dcacbc8c9ce334a4036e6a8f2201f6d3dc420c9fbd6a5262fd42e1e387090c4ffe1575b4a7d92081a5776844e5492
7
+ data.tar.gz: 4b02a0867a5ae9cc0e698df0308d91f9fa8b41a96e14ad5efd8b51e95659e3e20196a2d1c197e9dc6e0f96710f632e0d9295342e18e069b6313eac49a5841c72
@@ -3,9 +3,15 @@ require 'base64'
3
3
  module KDL
4
4
  module Types
5
5
  class Base64 < Value
6
+ RGX = /^[A-Za-z0-9+\/=]+$/.freeze
7
+
6
8
  def self.call(value, type = 'base64')
7
9
  return nil unless value.is_a? ::KDL::Value::String
8
10
 
11
+ unless RGX.match?(value.value)
12
+ raise ArgumentError, "invalid base64: #{value.value}"
13
+ end
14
+
9
15
  data = ::Base64.decode64(value.value)
10
16
  new(data, type: type)
11
17
  end
@@ -12,6 +12,8 @@ module KDL
12
12
  end
13
13
 
14
14
  def self.call(value, type = 'email')
15
+ return nil unless value.is_a? ::KDL::Value::String
16
+
15
17
  local, domain = Parser.new(value.value).parse
16
18
 
17
19
  new(value.value, type: type, local: local, domain: domain)
@@ -29,6 +31,8 @@ module KDL
29
31
  end
30
32
 
31
33
  def self.call(value, type = 'email')
34
+ return nil unless value.is_a? ::KDL::Value::String
35
+
32
36
  local, domain, unicode_domain = Email::Parser.new(value.value, idn: true).parse
33
37
 
34
38
  new("#{local}@#{domain}", type: type, local: local, domain: domain, unicode_domain: unicode_domain)
@@ -4,6 +4,8 @@ module KDL
4
4
  module Types
5
5
  class Hostname < Value
6
6
  def self.call(value, type = 'hostname')
7
+ return nil unless value.is_a? ::KDL::Value::String
8
+
7
9
  validator = Validator.new(value.value)
8
10
  raise ArgumentError, "invalid hostname #{value}" unless validator.valid?
9
11
 
@@ -21,6 +23,8 @@ module KDL
21
23
  end
22
24
 
23
25
  def self.call(value, type = 'idn-hostname')
26
+ return nil unless value.is_a? ::KDL::Value::String
27
+
24
28
  validator = Validator.new(value.value)
25
29
  raise ArgumentError, "invalid hostname #{value}" unless validator.valid?
26
30
 
@@ -53,7 +53,7 @@ module KDL
53
53
  when '+' then ReservedExpansion
54
54
  when '#' then FragmentExpansion
55
55
  when '.' then LabelExpansion
56
- when '/' then PathExpantion
56
+ when '/' then PathExpansion
57
57
  when ';' then ParameterExpansion
58
58
  when '?' then QueryExpansion
59
59
  when '&' then QueryContinuation
@@ -275,7 +275,7 @@ module KDL
275
275
  end
276
276
  end
277
277
 
278
- class PathExpantion < StringExpansion
278
+ class PathExpansion < StringExpansion
279
279
  def prefix
280
280
  '/'
281
281
  end
data/lib/kdl/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module KDL
2
- VERSION = "1.0.1"
2
+ VERSION = "1.0.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kdl
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Danielle Smith
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-12-13 00:00:00.000000000 Z
11
+ date: 2021-12-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: racc