summaryrefslogtreecommitdiff
path: root/url.c
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2010-12-12 21:49:52 -0800
committerLibravatar Junio C Hamano <gitster@pobox.com>2010-12-12 21:49:52 -0800
commita0078dee90e9b6baf17fa22cdeaadd8bec49e725 (patch)
tree5e080b2401222e5839a1d4bc6e3abadc9800e936 /url.c
parentMerge branch 'tc/format-patch-p' (diff)
parenthttp-fetch: rework url handling (diff)
downloadtgif-a0078dee90e9b6baf17fa22cdeaadd8bec49e725.tar.xz
Merge branch 'tc/http-urls-ends-with-slash'
* tc/http-urls-ends-with-slash: http-fetch: rework url handling http-push: add trailing slash at arg-parse time, instead of later on http-push: check path length before using it http-push: Normalise directory names when pushing to some WebDAV servers http-backend: use end_url_with_slash() url: add str wrapper for end_url_with_slash() shift end_url_with_slash() from http.[ch] to url.[ch] t5550-http-fetch: add test for http-fetch t5550-http-fetch: add missing '&&'
Diffstat (limited to 'url.c')
-rw-r--r--url.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/url.c b/url.c
index cd8f74f00c..6a5495960f 100644
--- a/url.c
+++ b/url.c
@@ -125,3 +125,17 @@ char *url_decode_parameter_value(const char **query)
struct strbuf out = STRBUF_INIT;
return url_decode_internal(query, "&", &out, 1);
}
+
+void end_url_with_slash(struct strbuf *buf, const char *url)
+{
+ strbuf_addstr(buf, url);
+ if (buf->len && buf->buf[buf->len - 1] != '/')
+ strbuf_addstr(buf, "/");
+}
+
+void str_end_url_with_slash(const char *url, char **dest) {
+ struct strbuf buf = STRBUF_INIT;
+ end_url_with_slash(&buf, url);
+ free(*dest);
+ *dest = strbuf_detach(&buf, NULL);
+}