2 * Copyright (C) 2003-2010 The Music Player Daemon Project
3 * http://www.musicpd.org
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
28 bool uri_has_scheme(const char *uri
)
30 return strstr(uri
, "://") != NULL
;
33 /* suffixes should be ascii only characters */
35 uri_get_suffix(const char *uri
)
37 const char *suffix
= strrchr(g_basename(uri
), '.');
43 if (strchr(suffix
, '/') != NULL
)
50 verify_uri_segment(const char *p
)
57 if (dots
<= 2 && (*p
== 0 || *p
== '/'))
60 q
= strchr(p
+ 1, '/');
61 return q
!= NULL
? q
: "";
65 uri_safe_local(const char *uri
)
68 uri
= verify_uri_segment(uri
);
82 uri_remove_auth(const char *uri
)
84 const char *auth
, *slash
, *at
;
87 if (strncmp(uri
, "http://", 7) == 0)
89 else if (strncmp(uri
, "https://", 8) == 0)
92 /* unrecognized URI */
95 slash
= strchr(auth
, '/');
97 slash
= auth
+ strlen(auth
);
99 at
= memchr(auth
, '@', slash
- auth
);
101 /* no auth info present, do nothing */
104 /* duplicate the full URI and then delete the auth
107 memmove(p
+ (auth
- uri
), p
+ (at
+ 1 - uri
),