aboutsummaryrefslogtreecommitdiffstats
path: root/src/uri.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2023-03-29 19:59:50 -0400
committerDavid Robillard <d@drobilla.net>2023-04-05 09:45:15 -0400
commitf93c3fdd6c7d6ca61bec55d3c1ffae7e7c793913 (patch)
tree749ae66010fb5b8bfcf398c29ce252f9138cce5b /src/uri.c
parentdd777c54b7585823be1f977e9dd887a5110a74f3 (diff)
downloadserd-f93c3fdd6c7d6ca61bec55d3c1ffae7e7c793913.tar.gz
serd-f93c3fdd6c7d6ca61bec55d3c1ffae7e7c793913.tar.bz2
serd-f93c3fdd6c7d6ca61bec55d3c1ffae7e7c793913.zip
Fix relative URI creation
Diffstat (limited to 'src/uri.c')
-rw-r--r--src/uri.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/uri.c b/src/uri.c
index 8acb79b3..dcdd8083 100644
--- a/src/uri.c
+++ b/src/uri.c
@@ -1,4 +1,4 @@
-// Copyright 2011-2020 David Robillard <d@drobilla.net>
+// Copyright 2011-2023 David Robillard <d@drobilla.net>
// SPDX-License-Identifier: ISC
#include "string_utils.h"
@@ -428,10 +428,6 @@ write_rel_path(SerdSink sink,
len += sink("../", 3, stream);
}
- if (last_shared_sep == 0 && up == 0) {
- len += sink("/", 1, stream);
- }
-
// Write suffix
return len + write_path_tail(sink, stream, uri, last_shared_sep + 1);
}
@@ -468,8 +464,12 @@ serd_uri_serialise_relative(const SerdURI* const uri,
if (uri->authority.buf) {
len += sink("//", 2, stream);
len += sink(uri->authority.buf, uri->authority.len, stream);
- if (uri->authority.len > 0 &&
- uri->authority.buf[uri->authority.len - 1] != '/' &&
+
+ const bool authority_ends_with_slash =
+ (uri->authority.len > 0 &&
+ uri->authority.buf[uri->authority.len - 1] == '/');
+
+ if (!authority_ends_with_slash &&
serd_uri_path_starts_without_slash(uri)) {
// Special case: ensure path begins with a slash
// https://tools.ietf.org/html/rfc3986#section-3.2