Skip to content

Commit 4dc3252

Browse files
csk-abletonglynos
authored andcommitted
Fix building URIs that have only a scheme and an absolute path (#113)
1 parent cf62c91 commit 4dc3252

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

src/uri.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,8 @@ void uri::initialize(optional<string_type> scheme,
129129
if (*it == ':') {
130130
++it;
131131
}
132-
if (*it == '/') {
133-
++it;
134-
if (*it == '/') {
135-
++it;
136-
}
132+
if (*it == '/' && *(it + 1) == '/') {
133+
it += 2;
137134
}
138135
}
139136

test/uri_builder_test.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -764,3 +764,14 @@ TEST(builder_test, non_const_non_array_string_literals_should_work) {
764764
;
765765
ASSERT_EQ("http://example.com/foo", builder.uri());
766766
}
767+
768+
TEST(builder_test, scheme_and_absolute_path) {
769+
network::uri_builder builder;
770+
builder
771+
.scheme("foo")
772+
.path("/bar")
773+
;
774+
ASSERT_EQ("foo:/bar", builder.uri());
775+
ASSERT_EQ("foo", builder.uri().scheme());
776+
ASSERT_EQ("/bar", builder.uri().path());
777+
}

0 commit comments

Comments
 (0)