changeset 21125:4aff19cc00bb

Also support absolute url redirection, e.g. http://www.youtube.com/v/buKaqRG2SFA (video does not play anyway though).
author reimar
date Tue, 21 Nov 2006 16:26:38 +0000
parents 2e0938ba9756
children 83dc11e40f28
files stream/url.c
diffstat 1 files changed, 6 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/stream/url.c	Tue Nov 21 16:23:35 2006 +0000
+++ b/stream/url.c	Tue Nov 21 16:26:38 2006 +0000
@@ -22,10 +22,15 @@
 URL_t *url_redirect(URL_t **url, const char *redir) {
   URL_t *u = *url;
   URL_t *res;
-  if (!strchr(redir, '/')) {
+  if (!strchr(redir, '/') || *redir == '/') {
     char *tmp;
     char *newurl = malloc(strlen(u->url) + strlen(redir) + 1);
     strcpy(newurl, u->url);
+    if (*redir == '/') {
+      redir++;
+      tmp = strstr(newurl, "://");
+      if (tmp) tmp = strchr(tmp + 3, '/');
+    } else
     tmp = strrchr(newurl, '/');
     if (tmp) tmp[1] = 0;
     strcat(newurl, redir);