test2("https://1l-lh.a.net/i/1LIVE_HDS@179577/master.m3u8");
test2("ftp://u:p%2B%2F2@ftp.pbt.com/ExportHD.mpg");
test2("https://key.dns.com?key_id=2&model_id=12345&&access_key=");
+ test2("http://example.com#tag");
return 0;
}
char *hostname, int hostname_size,
int *port_ptr, char *path, int path_size, const char *url)
{
- const char *p, *ls, *ls2, *at, *at2, *col, *brk;
+ const char *p, *ls, *at, *at2, *col, *brk;
if (port_ptr)
*port_ptr = -1;
}
/* separate path from hostname */
- ls = strchr(p, '/');
- ls2 = strchr(p, '?');
- if (!ls)
- ls = ls2;
- else if (ls && ls2)
- ls = FFMIN(ls, ls2);
- if (ls)
- av_strlcpy(path, ls, path_size);
- else
- ls = &p[strlen(p)]; // XXX
+ ls = p + strcspn(p, "/?#");
+ av_strlcpy(path, ls, path_size);
/* the rest is hostname, use that to parse auth/port */
if (ls != p) {
https://1l-lh.a.net/i/1LIVE_HDS@179577/master.m3u8 => https 1l-lh.a.net -1 /i/1LIVE_HDS@179577/master.m3u8
ftp://u:p%2B%2F2@ftp.pbt.com/ExportHD.mpg => ftp u:p%2B%2F2 ftp.pbt.com -1 /ExportHD.mpg
https://key.dns.com?key_id=2&model_id=12345&&access_key= => https key.dns.com -1 ?key_id=2&model_id=12345&&access_key=
+http://example.com#tag => http example.com -1 #tag