diff --git a/cmd/serve/dlna/dlna.go b/cmd/serve/dlna/dlna.go
index 960e7db32..b430634a4 100644
--- a/cmd/serve/dlna/dlna.go
+++ b/cmd/serve/dlna/dlna.go
@@ -86,6 +86,13 @@ var services = []*service{
},
}
+func init() {
+ for _, s := range services {
+ p := path.Join("/scpd", s.ServiceId)
+ s.SCPDURL = p
+ }
+}
+
func devices() []string {
return []string{
"urn:schemas-upnp-org:device:MediaServer:1",
@@ -250,9 +257,6 @@ func (s *server) initMux(mux *http.ServeMux) {
// Install handlers to serve SCPD for each UPnP service.
for _, s := range services {
- p := path.Join("/scpd", s.ServiceId)
- s.SCPDURL = p
-
mux.HandleFunc(s.SCPDURL, func(serviceDesc string) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("content-type", `text/xml; charset="utf-8"`)
diff --git a/cmd/serve/dlna/dlna_test.go b/cmd/serve/dlna/dlna_test.go
index 0f5c59188..a2ef03445 100644
--- a/cmd/serve/dlna/dlna_test.go
+++ b/cmd/serve/dlna/dlna_test.go
@@ -59,6 +59,8 @@ func TestRootSCPD(t *testing.T) {
// Make sure that the SCPD contains a CDS service.
require.Contains(t, string(body),
"urn:schemas-upnp-org:service:ContentDirectory:1")
+ // Ensure that the SCPD url is configured.
+ require.Regexp(t, "/.*", string(body))
}
// Make sure that it serves content from the remote.