util/UriUtil: make variables more local
This commit is contained in:
parent
c880099deb
commit
7640d333f4
@ -74,8 +74,6 @@ uri_get_suffix(const char *uri, UriSuffixBuffer &buffer)
|
|||||||
static const char *
|
static const char *
|
||||||
verify_uri_segment(const char *p)
|
verify_uri_segment(const char *p)
|
||||||
{
|
{
|
||||||
const char *q;
|
|
||||||
|
|
||||||
unsigned dots = 0;
|
unsigned dots = 0;
|
||||||
while (*p == '.') {
|
while (*p == '.') {
|
||||||
++p;
|
++p;
|
||||||
@ -85,7 +83,7 @@ verify_uri_segment(const char *p)
|
|||||||
if (dots <= 2 && (*p == 0 || *p == '/'))
|
if (dots <= 2 && (*p == 0 || *p == '/'))
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
q = strchr(p + 1, '/');
|
const char *q = strchr(p + 1, '/');
|
||||||
return q != nullptr ? q : "";
|
return q != nullptr ? q : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,8 +107,7 @@ uri_safe_local(const char *uri)
|
|||||||
std::string
|
std::string
|
||||||
uri_remove_auth(const char *uri)
|
uri_remove_auth(const char *uri)
|
||||||
{
|
{
|
||||||
const char *auth, *slash, *at;
|
const char *auth;
|
||||||
|
|
||||||
if (memcmp(uri, "http://", 7) == 0)
|
if (memcmp(uri, "http://", 7) == 0)
|
||||||
auth = uri + 7;
|
auth = uri + 7;
|
||||||
else if (memcmp(uri, "https://", 8) == 0)
|
else if (memcmp(uri, "https://", 8) == 0)
|
||||||
@ -121,11 +118,11 @@ uri_remove_auth(const char *uri)
|
|||||||
/* unrecognized URI */
|
/* unrecognized URI */
|
||||||
return std::string();
|
return std::string();
|
||||||
|
|
||||||
slash = strchr(auth, '/');
|
const char *slash = strchr(auth, '/');
|
||||||
if (slash == nullptr)
|
if (slash == nullptr)
|
||||||
slash = auth + strlen(auth);
|
slash = auth + strlen(auth);
|
||||||
|
|
||||||
at = (const char *)memchr(auth, '@', slash - auth);
|
const char *at = (const char *)memchr(auth, '@', slash - auth);
|
||||||
if (at == nullptr)
|
if (at == nullptr)
|
||||||
/* no auth info present, do nothing */
|
/* no auth info present, do nothing */
|
||||||
return std::string();
|
return std::string();
|
||||||
|
Loading…
Reference in New Issue
Block a user