~singpolyma/dhall-ruby

17eb9ccd04c09a66d231829c7cadaceb78270897 — Stephen Paul Weber 2 years ago 68fb06e
Fix query string on newer ruby

Ruby URI#query= encodes certain characters without asking. This
workaround allows us to preserve exact author intent.
2 files changed, 8 insertions(+), 9 deletions(-)

M lib/dhall/binary.rb
M lib/dhall/parser.rb
M lib/dhall/binary.rb => lib/dhall/binary.rb +5 -7
@@ 228,15 228,13 @@ module Dhall

		class URI
			def self.decode(headers, authority, *path, query)
				new(
					headers: headers,
					uri:     ::URI.scheme_list[name.split(/::/).last.upcase].build(
						Parser.parse(authority, root: :authority).value.merge(
							path:  Util.path_components_to_uri(*path).path,
							query: query
						)
				uri = ::URI.scheme_list[name.split(/::/).last.upcase].build(
					Parser.parse(authority, root: :authority).value.merge(
						path: Util.path_components_to_uri(*path).path
					)
				)
				uri.instance_variable_set(:@query, query)
				new(headers: headers, uri: uri)
			end
		end


M lib/dhall/parser.rb => lib/dhall/parser.rb +3 -2
@@ 564,11 564,12 @@ module Dhall
			def value
				uri = http(:scheme).build(
					http(:authority).merge(
						path:  http(:url_path) || "/",
						query: http(:query)
						path: http(:url_path) || "/"
					)
				)

				uri.instance_variable_set(:@query, http(:query))

				SCHEME.fetch(uri.scheme).new(
					headers: capture(:import_expression)&.value,
					uri:     uri