Method: OpenAI::Internal::Util.join_parsed_uri
- Defined in:
- lib/openai/internal/util.rb
.join_parsed_uri(lhs, rhs) ⇒ URI::Generic
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 |
# File 'lib/openai/internal/util.rb', line 345 def join_parsed_uri(lhs, rhs) base_path, base_query = lhs.fetch_values(:path, :query) slashed = base_path.end_with?("/") ? base_path : "#{base_path}/" parsed_path, parsed_query = parse_uri(rhs.fetch(:path)).fetch_values(:path, :query) override = URI::Generic.build(**rhs.slice(:scheme, :host, :port), path: parsed_path) joined = URI.join(URI::Generic.build(lhs.except(:path, :query)), slashed, override) query = deep_merge( joined.path == base_path ? base_query : {}, parsed_query, rhs[:query].to_h, concat: true ) joined.query = encode_query(query) joined end |