File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -253,25 +253,16 @@ uri::string_type fragment(const uri &uri_) {
253253 return uri_.fragment ();
254254}
255255
256+ inline
257+ uri::string_type hierarchical_part (const uri &uri_) {
258+ return uri::string_type (boost::begin (uri_.user_info_range ()),
259+ boost::end (uri_.path_range ()));
260+ }
261+
256262inline
257263uri::string_type authority (const uri &uri_) {
258- uri::string_type port (uri_.port ());
259- uri::string_type authority;
260- if (uri_.user_info_range ())
261- {
262- boost::copy (uri_.user_info_range (), std::back_inserter (authority));
263- authority.push_back (' @' );
264- }
265- if (uri_.host_range ())
266- {
267- boost::copy (uri_.host (), std::back_inserter (authority));
268- }
269- if (uri_.port_range ())
270- {
271- authority.push_back (' :' );
272- boost::copy (uri_.port_range (), std::back_inserter (authority));
273- }
274- return authority;
264+ return uri::string_type (boost::begin (uri_.user_info_range ()),
265+ boost::end (uri_.port_range ()));
275266}
276267
277268inline
Original file line number Diff line number Diff line change @@ -306,12 +306,30 @@ BOOST_AUTO_TEST_CASE(username_test) {
306306 BOOST_CHECK_EQUAL (uri::password (instance), " password" );
307307}
308308
309+ BOOST_AUTO_TEST_CASE (hierarchical_part_test) {
310+ uri::uri instance (" http://user:password@www.example.com:80/path?query#fragment" );
311+ BOOST_REQUIRE (uri::valid (instance));
312+ BOOST_CHECK_EQUAL (uri::hierarchical_part (instance), " user:password@www.example.com:80/path" );
313+ }
314+
315+ BOOST_AUTO_TEST_CASE (partial_hierarchical_part_test) {
316+ uri::uri instance (" http://www.example.com?query#fragment" );
317+ BOOST_REQUIRE (uri::valid (instance));
318+ BOOST_CHECK_EQUAL (uri::hierarchical_part (instance), " www.example.com" );
319+ }
320+
309321BOOST_AUTO_TEST_CASE (authority_test) {
310322 uri::uri instance (" http://user:password@www.example.com:80/path?query#fragment" );
311323 BOOST_REQUIRE (uri::valid (instance));
312324 BOOST_CHECK_EQUAL (uri::authority (instance), " user:password@www.example.com:80" );
313325}
314326
327+ BOOST_AUTO_TEST_CASE (partial_authority_test) {
328+ uri::uri instance (" http://www.example.com/path?query#fragment" );
329+ BOOST_REQUIRE (uri::valid (instance));
330+ BOOST_CHECK_EQUAL (uri::authority (instance), " www.example.com" );
331+ }
332+
315333BOOST_AUTO_TEST_CASE (http_query_map_test) {
316334 uri::uri instance (" http://user:password@www.example.com:80/path?query=something#fragment" );
317335 BOOST_REQUIRE (uri::valid (instance));
You can’t perform that action at this time.
0 commit comments