diff options
author | 2010-12-14 07:36:10 -0800 | |
---|---|---|
committer | 2010-12-14 07:36:10 -0800 | |
commit | 6b090e1710dbdf3f2c9f46c7f089ce34399b35c5 (patch) | |
tree | 5103919c6668e99e22db598c0f57299e14c6393b /url.c | |
parent | Merge branch 'nd/maint-hide-checkout-index-from-error' into maint (diff) | |
parent | http-fetch: rework url handling (diff) | |
download | tgif-6b090e1710dbdf3f2c9f46c7f089ce34399b35c5.tar.xz |
Merge branch 'tc/http-urls-ends-with-slash' into maint
* 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.c | 14 |
1 files changed, 14 insertions, 0 deletions
@@ -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); +} |