diff -r ad419882e06e -r 178dc32c8c9a dav/main.c --- a/dav/main.c Sun Jun 17 06:50:38 2018 +0200 +++ b/dav/main.c Sun Jun 17 07:11:31 2018 +0200 @@ -1964,7 +1964,7 @@ int cmd_repository_url(CmdArgs *args) { if(args->argc != 1) { fprintf(stderr, "Too few arguments\n"); - fprintf(stderr, "Usage: dav repository-url \n"); + fprintf(stderr, "Usage: dav repository-url [-p] \n"); return -1; } @@ -1972,11 +1972,35 @@ Repository* repo = get_repository(reponame); if(repo) { sstr_t url = sstr(repo->url); - if(url.ptr[url.length-1] == '/') { - printf("%s\n", repo->url); + if(repo->user && !cmd_getoption(args, "plain")) { + int hostindex = 0; + if(sstrprefix(url, S("https://"))) { + printf("https://"); + hostindex = 8; + } else if(sstrprefix(url, S("http://"))) { + printf("http://"); + hostindex = 7; + } + printf("%s", repo->user); + if(repo->password) { + CURL *curl = curl_easy_init(); + char *pw = curl_easy_escape( + curl, + repo->password, + strlen(repo->password)); + printf(":%s", pw); + curl_free(pw); + curl_easy_cleanup(curl); + } + putchar('@'); + printf("%.*s", (int)url.length-hostindex, url.ptr+hostindex); } else { - printf("%s/\n", repo->url); + printf("%s", url.ptr); } + if(url.ptr[url.length-1] != '/') { + putchar('/'); + } + putchar('\n'); } else { fprintf(stderr, "Repository %s does not exist.\n", reponame.ptr); return -1;