diff options
Diffstat (limited to 'src/util/UriUtil.cxx')
-rw-r--r-- | src/util/UriUtil.cxx | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/util/UriUtil.cxx b/src/util/UriUtil.cxx index 2609db2cf..a549f7938 100644 --- a/src/util/UriUtil.cxx +++ b/src/util/UriUtil.cxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2013 The Music Player Daemon Project + * Copyright (C) 2003-2014 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify @@ -27,6 +27,16 @@ bool uri_has_scheme(const char *uri) return strstr(uri, "://") != nullptr; } +std::string +uri_get_scheme(const char *uri) +{ + const char *end = strstr(uri, "://"); + if (end == nullptr) + end = uri; + + return std::string(uri, end); +} + /* suffixes should be ascii only characters */ const char * uri_get_suffix(const char *uri) @@ -88,6 +98,8 @@ uri_remove_auth(const char *uri) auth = uri + 7; else if (memcmp(uri, "https://", 8) == 0) auth = uri + 8; + else if (memcmp(uri, "ftp://", 6) == 0) + auth = uri + 6; else /* unrecognized URI */ return std::string(); |