Sha256: 60969627bf9ed47aa0c71233c9a1a28eb33a2c32bca93ef48de767ddb380af0a
Contents?: true
Size: 988 Bytes
Versions: 23
Compression:
Stored size: 988 Bytes
Contents
# frozen_string_literal: true module LedgerSync module Util class URLHelpers def self.merge_params_in_url(args = {}) params = args.fetch(:params) uri = args.fetch(:url) uri = URI.parse(uri) unless uri.is_a?(URI::HTTPS) || uri.is_a?(URI::HTTP) uri.query = URI.encode_www_form( params.inject(URI.decode_www_form(String(uri.query))) { |prev, param| prev << param } ) uri.to_s end def self.merge_params_in_path(args = {}) params = args.fetch(:params) path = args.fetch(:path) root, str_params = path.split('?') str_params = Rack::Utils.parse_nested_query(str_params) [ root, Rack::Utils.build_query(str_params.merge(HashHelpers.deep_stringify_keys(params))) ].compact.join('?') end def self.id_from_url(args = {}) uri = args.fetch(:url) URI.parse(uri).path.split('/').last end end end end
Version data entries
23 entries across 23 versions & 1 rubygems