File tree 2 files changed +14
-12
lines changed
2 files changed +14
-12
lines changed Original file line number Diff line number Diff line change @@ -1133,21 +1133,16 @@ def merge(oth)
1133
1133
base . fragment = ( nil )
1134
1134
1135
1135
# RFC2396, Section 5.2, 4)
1136
- if !authority
1137
- base . set_path ( merge_path ( base . path , rel . path ) ) if base . path && rel . path
1138
- else
1139
- # RFC2396, Section 5.2, 4)
1140
- base . set_path ( rel . path ) if rel . path
1136
+ if authority
1137
+ base . set_userinfo ( rel . userinfo )
1138
+ base . set_host ( rel . host )
1139
+ base . set_port ( rel . port || base . default_port )
1140
+ base . set_path ( rel . path )
1141
+ elsif base . path && rel . path
1142
+ base . set_path ( merge_path ( base . path , rel . path ) )
1141
1143
end
1142
1144
1143
1145
# RFC2396, Section 5.2, 7)
1144
- if rel . userinfo
1145
- base . set_userinfo ( rel . userinfo )
1146
- else
1147
- base . set_userinfo ( nil )
1148
- end
1149
- base . set_host ( rel . host ) if rel . host
1150
- base . set_port ( rel . port ) if rel . port
1151
1146
base . query = rel . query if rel . query
1152
1147
base . fragment = ( rel . fragment ) if rel . fragment
1153
1148
Original file line number Diff line number Diff line change @@ -278,6 +278,13 @@ def test_merge
278
278
assert_equal ( u0 , u1 )
279
279
end
280
280
281
+ def test_merge_authority
282
+ u = URI . parse ( 'http://user:[email protected] :8080' )
283
+ u0 = URI . parse ( 'http://new.example.org/path' )
284
+ u1 = u . merge ( '//new.example.org/path' )
285
+ assert_equal ( u0 , u1 )
286
+ end
287
+
281
288
def test_route
282
289
url = URI . parse ( 'http://hoge/a.html' ) . route_to ( 'http://hoge/b.html' )
283
290
assert_equal ( 'b.html' , url . to_s )
You can’t perform that action at this time.
0 commit comments