Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Normalize service URLs

  • Loading branch information...
commit 1d755523a4f188030a5af11856c7b2d29ba0e13c 1 parent 3b7161c
@andoma authored
Showing with 21 additions and 2 deletions.
  1. +21 −2 src/service.c
View
23 src/service.c
@@ -167,6 +167,25 @@ service_reprobe(service_t *s)
hts_cond_signal(&service_cond);
}
+
+/**
+ *
+ */
+static void
+seturl(service_t *s, const char *url)
+{
+ char urlbuf[URL_MAX];
+ backend_t *be;
+
+ be = backend_canhandle(url);
+ if(be != NULL && be->be_normalize != NULL &&
+ !be->be_normalize(url, urlbuf, sizeof(urlbuf)))
+ mystrset(&s->s_url, urlbuf);
+ else
+ mystrset(&s->s_url, url);
+}
+
+
/**
*
*/
@@ -184,7 +203,7 @@ service_create(const char *id,
s->s_type = type;
p = s->s_global_root = prop_create(NULL, id);
s->s_type_root = prop_create(NULL, id);
- mystrset(&s->s_url, url);
+ seturl(s, url);
prop_set_string(prop_create(p, "title"), title);
prop_set_string(prop_create(p, "icon"), icon);
@@ -294,7 +313,7 @@ service_set_url(service_t *s, const char *url)
prop_set_string(prop_create(s->s_global_root, "url"), url);
hts_mutex_lock(&service_mutex);
- mystrset(&s->s_url, url);
+ seturl(s, url);
service_reprobe(s);
hts_mutex_unlock(&service_mutex);
}
Please sign in to comment.
Something went wrong with that request. Please try again.