diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/uri.c | 56 |
1 files changed, 26 insertions, 30 deletions
@@ -353,41 +353,37 @@ serd_uri_serialise(const SerdURI* uri, SerdSink sink, void* stream) WRITE("//", 2); WRITE(uri->authority.buf, uri->authority.len); } - if (uri->path_base.len || uri->path.len) { - if (!uri->path.buf && (uri->fragment.buf || uri->query.buf)) { - WRITE_COMPONENT("", uri->path_base, ""); - } else if (uri->path.buf) { - const uint8_t* begin = uri->path.buf; - const uint8_t* const end = uri->path.buf + uri->path.len; + if (!uri->path.buf) { + WRITE_COMPONENT("", uri->path_base, ""); + } else { + const uint8_t* begin = uri->path.buf; + const uint8_t* const end = uri->path.buf + uri->path.len; - size_t up; - begin = remove_dot_segments(uri->path.buf, uri->path.len, &up); - ++up; + size_t up; + begin = remove_dot_segments(uri->path.buf, uri->path.len, &up); - if (uri->path_base.buf) { - // Find the up'th last slash - const uint8_t* base_last = (uri->path_base.buf - + uri->path_base.len - 1); - do { - if (*base_last == '/') { - --up; - } - } while (up > 0 && (--base_last > uri->path_base.buf)); + if (uri->path_base.buf) { + // Find the up'th last slash + const uint8_t* base_last = (uri->path_base.buf + + uri->path_base.len - 1); + ++up; + do { + if (*base_last == '/') { + --up; + } + } while (up > 0 && (--base_last > uri->path_base.buf)); - // Write base URI prefix - const size_t base_len = base_last - uri->path_base.buf + 1; - WRITE(uri->path_base.buf, base_len); + // Write base URI prefix + const size_t base_len = base_last - uri->path_base.buf + 1; + WRITE(uri->path_base.buf, base_len); - } else { - // Relative path is just query or fragment, append to base URI - WRITE_COMPONENT("", uri->path_base, ""); - } - - // Write URI suffix - WRITE(begin, end - begin); + } else { + // Relative path is just query or fragment, append to base URI + WRITE_COMPONENT("", uri->path_base, ""); } - } else { - WRITE_COMPONENT("", uri->path, ""); + + // Write URI suffix + WRITE(begin, end - begin); } WRITE_COMPONENT("?", uri->query, ""); if (uri->fragment.buf) { |