Skip to content

Commit 27301cd

Browse files
committed
net: function to identify ipv6 addresses in URLs
1 parent 953dee2 commit 27301cd

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/net.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,11 @@ bool git_net_url_is_default_port(git_net_url *url)
345345
return false;
346346
}
347347

348+
bool git_net_url_is_ipv6(git_net_url *url)
349+
{
350+
return (strchr(url->host, ':') != NULL);
351+
}
352+
348353
void git_net_url_swap(git_net_url *a, git_net_url *b)
349354
{
350355
git_net_url tmp = GIT_NET_URL_INIT;

src/net.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ extern bool git_net_url_valid(git_net_url *url);
3636
/** Returns true if the URL is on the default port. */
3737
extern bool git_net_url_is_default_port(git_net_url *url);
3838

39+
/** Returns true if the host portion of the URL is an ipv6 address. */
40+
extern bool git_net_url_is_ipv6(git_net_url *url);
41+
3942
/* Applies a redirect to the URL with a git-aware service suffix. */
4043
extern int git_net_url_apply_redirect(
4144
git_net_url *url,

0 commit comments

Comments
 (0)