File tree Expand file tree Collapse file tree 2 files changed +14
-4
lines changed Expand file tree Collapse file tree 2 files changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -321,8 +321,8 @@ auto URI::path(const std::string &path) -> URI & {
321
321
}
322
322
323
323
const auto is_relative_path = path.starts_with (" ." );
324
- if (is_relative_path) {
325
- throw URIError{" You cannot set a relative path" };
324
+ if (is_relative_path && this -> is_absolute () ) {
325
+ throw URIError{" You cannot set a relative path to an absolute URI " };
326
326
}
327
327
328
328
if (path == " /" ) {
@@ -341,8 +341,8 @@ auto URI::path(std::string &&path) -> URI & {
341
341
}
342
342
343
343
const auto is_relative_path = path.starts_with (" ." );
344
- if (is_relative_path) {
345
- throw URIError{" You cannot set a relative path" };
344
+ if (is_relative_path && this -> is_absolute () ) {
345
+ throw URIError{" You cannot set a relative path to an absolute URI " };
346
346
}
347
347
348
348
if (path == " /" ) {
Original file line number Diff line number Diff line change @@ -285,6 +285,16 @@ TEST(URI_path_setter_no_scheme, set_path_with_port) {
285
285
EXPECT_EQ (path, " " );
286
286
}
287
287
288
+ TEST (URI_path_setter, lowercase_relative_path) {
289
+ sourcemeta::core::URI uri{" ../SERVER.JSON" };
290
+ EXPECT_EQ (uri.recompose (), " ../SERVER.JSON" );
291
+ uri.path (" ../server.json" );
292
+ EXPECT_EQ (uri.recompose (), " ../server.json" );
293
+ const auto const_path{" ../foo.json" };
294
+ uri.path (const_path);
295
+ EXPECT_EQ (uri.recompose (), " ../foo.json" );
296
+ }
297
+
288
298
TEST (URI_path, append_path_without_path_from_root) {
289
299
sourcemeta::core::URI uri{" http://example.com:8080" };
290
300
uri.append_path (" /test" );
You can’t perform that action at this time.
0 commit comments