Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3b9d40f

Browse files
committed
[URI] Added another accessor for the hierarchical part.
1 parentc6ea5ff commit3b9d40f

File tree

2 files changed

+26
-17
lines changed

2 files changed

+26
-17
lines changed

‎boost/network/uri/uri.hpp‎

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -253,25 +253,16 @@ uri::string_type fragment(const uri &uri_) {
253253
return uri_.fragment();
254254
}
255255

256+
inline
257+
uri::string_typehierarchical_part(const uri &uri_) {
258+
returnuri::string_type(boost::begin(uri_.user_info_range()),
259+
boost::end(uri_.path_range()));
260+
}
261+
256262
inline
257263
uri::string_typeauthority(const uri &uri_) {
258-
uri::string_typeport(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+
returnuri::string_type(boost::begin(uri_.user_info_range()),
265+
boost::end(uri_.port_range()));
275266
}
276267

277268
inline

‎libs/network/test/uri/url_test.cpp‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff 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::uriinstance("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::uriinstance("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+
309321
BOOST_AUTO_TEST_CASE(authority_test) {
310322
uri::uriinstance("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::uriinstance("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+
315333
BOOST_AUTO_TEST_CASE(http_query_map_test) {
316334
uri::uriinstance("http://user:password@www.example.com:80/path?query=something#fragment");
317335
BOOST_REQUIRE(uri::valid(instance));

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp