microsoft_kiota_abstractions 0.24.0 → 0.24.1

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: ec82d13c67d7a99abb8072fc1bfb3e1b7926ae95462caca4f9260993e09583bb
4
- data.tar.gz: 910a8c047e114d477144c8769f27efe623a56486800422811cb772b612680ffd
3
+ metadata.gz: 1aa2e08176306a273c14cf184dbdb9067a5d9ec76159da97fe2edb2f55d7422e
4
+ data.tar.gz: f9ee50ea82f77d315e57cc843edb368ce616b4c26a0341b68430302d2c4f909a
5
5
  SHA512:
6
- metadata.gz: ca47b5b57ae1e5df01a5921f36d85f231ca34d23365f91e0c7c785617e8b82017559e5e2f3bdae5558f19a8c428fe91b9b2e7c71c3e9c9b2a767d50f43d1516b
7
- data.tar.gz: 2d3485190a43513db40db1e6f0022982076552d5eb2162a7580c9f6551314feecc532ab20a1cd0aeef35c918d7f539df3b64e7517518188508d4343c38630904
6
+ metadata.gz: 660a942a75900da8b91320cf79fc5c26057309d4129ea34bd3359e2f6bccd0fc37d0b76a80cc01f5d89342679ce338bd883391859008548a3b83d62124fa5f31
7
+ data.tar.gz: 873d46c83bb047007c30d801e69629f5bc2c60b33e5df063d89446b6b5163642febece72decaa88b147d5814ecb61f655417e8eeae364ac3bad6df647f247da8
@@ -8,14 +8,18 @@ module MicrosoftKiotaAbstractions
8
8
  class AllowedHostsValidator
9
9
  # creates a new AllocatedHostsValidator with provided values
10
10
  def initialize(allowed_hosts)
11
- @allowed_hosts = {}
12
- allowed_hosts.each { |host| @allowed_hosts[host.downcase] = true }
11
+ self.allowed_hosts = allowed_hosts
13
12
  end
14
13
 
15
14
  # sets the list of valid hosts with provided value (val)
16
15
  def allowed_hosts=(val)
17
- @allowed_hosts = {}
18
- val.each { |host| @allowed_hosts[host.downcase] = true }
16
+ hosts = {}
17
+ val.each do |host|
18
+ raise ArgumentError, "host should not contain http or https prefix: #{host}" if host.match?(%r{\Ahttps?://}i)
19
+
20
+ hosts[host.downcase] = true
21
+ end
22
+ @allowed_hosts = hosts
19
23
  end
20
24
 
21
25
  # checks whether the provided host is valid
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'date'
4
+ require 'time'
3
5
  require 'uri'
4
6
  require 'stduritemplate'
5
7
  require_relative 'http_method'
@@ -32,7 +34,8 @@ module MicrosoftKiotaAbstractions
32
34
  return @uri unless @uri.nil?
33
35
 
34
36
  if path_parameters[@@raw_url_key].nil?
35
- return URI(StdUriTemplate.expand(@url_template, path_parameters.merge(query_parameters)))
37
+ values = path_parameters.merge(query_parameters).transform_values { |v| template_value(v) }
38
+ return URI(StdUriTemplate.expand(@url_template, values))
36
39
  end
37
40
 
38
41
  self.uri = path_parameters[@@raw_url_key]
@@ -144,5 +147,19 @@ module MicrosoftKiotaAbstractions
144
147
  query_parameters[key] = value unless value.nil?
145
148
  end
146
149
  end
150
+
151
+ private
152
+
153
+ # the template engine only takes strings, numbers, booleans and lists of them
154
+ def template_value(value)
155
+ case value
156
+ when nil, String, Integer, Float, true, false then value
157
+ when Array then value.map { |v| template_value(v) }
158
+ when Hash then value.transform_values { |v| template_value(v) }
159
+ when Date, Time then value.iso8601
160
+ when MicrosoftKiotaAbstractions::ISODuration then value.string
161
+ else value.to_s
162
+ end
163
+ end
147
164
  end
148
165
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MicrosoftKiotaAbstractions
4
- VERSION = '0.24.0' # x-release-please-version
4
+ VERSION = '0.24.1' # x-release-please-version
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: microsoft_kiota_abstractions
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.24.0
4
+ version: 0.24.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Microsoft Corporation