Hash :
e02e6a5c
Author :
Date :
2022-01-11T10:19:40
url: introduce git_net_str_is_url We occasionally need to determine whether a given string is a URL or something else. (The "something else" may be a git path in a different format, like scp formatting, which needs to be handled differently.)
#include "clar_libgit2.h"
#include "net.h"
void test_network_url_valid__test(void)
{
cl_assert(git_net_str_is_url("http://example.com/"));
cl_assert(git_net_str_is_url("file://localhost/tmp/foo/"));
cl_assert(git_net_str_is_url("ssh://user@host:42/tmp"));
cl_assert(git_net_str_is_url("git+ssh://user@host:42/tmp"));
cl_assert(git_net_str_is_url("ssh+git://user@host:42/tmp"));
cl_assert(git_net_str_is_url("https://user:pass@example.com/foo/bar"));
cl_assert(!git_net_str_is_url("host:foo.git"));
cl_assert(!git_net_str_is_url("host:/foo.git"));
cl_assert(!git_net_str_is_url("[host:42]:/foo.git"));
cl_assert(!git_net_str_is_url("[user@host:42]:/foo.git"));
}