Skip to content

Commit a1e088f

Browse files
fix: absolutely qualified uris should always override the default
1 parent 76f82c2 commit a1e088f

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

lib/onebusaway_sdk/internal/util.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -346,8 +346,9 @@ def join_parsed_uri(lhs, rhs)
346346
base_path, base_query = lhs.fetch_values(:path, :query)
347347
slashed = base_path.end_with?("/") ? base_path : "#{base_path}/"
348348

349-
parsed_path, parsed_query = parse_uri(rhs.fetch(:path)).fetch_values(:path, :query)
350-
override = URI::Generic.build(**rhs.slice(:scheme, :host, :port), path: parsed_path)
349+
merged = {**parse_uri(rhs.fetch(:path)), **rhs.except(:path, :query)}
350+
parsed_path, parsed_query = merged.fetch_values(:path, :query)
351+
override = URI::Generic.build(**merged.slice(:scheme, :host, :port), path: parsed_path)
351352

352353
joined = URI.join(URI::Generic.build(lhs.except(:path, :query)), slashed, override)
353354
query = deep_merge(

test/onebusaway_sdk/internal/util_test.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,14 @@ def test_joining
124124
path: "/c",
125125
query: {"d" => ["e"]}
126126
}
127+
],
128+
[
129+
"h://a.b/c?d=e",
130+
"h://nope",
131+
{
132+
path: "h://a.b/c",
133+
query: {"d" => ["e"]}
134+
}
127135
]
128136
]
129137

0 commit comments

Comments
 (0)