The following pull request was submitted through Github. It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/2113
This e-mail was sent by the LXC bot, direct replies will not reach the author unless they happen to be subscribed to this list. === Description (from pull-request) === This avoids generating URLs which Go then drops on the floor. Closes #2112 Signed-off-by: Stéphane Graber <stgra...@ubuntu.com>
From 61d22f1df240fc52e4cafbbefe9589bec3d2e088 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgra...@ubuntu.com> Date: Mon, 13 Jun 2016 13:48:06 -0400 Subject: [PATCH] Normalize the URLs in the client MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This avoids generating URLs which Go then drops on the floor. Closes #2112 Signed-off-by: Stéphane Graber <stgra...@ubuntu.com> --- client.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/client.go b/client.go index 22f3fbb..eefaa16 100644 --- a/client.go +++ b/client.go @@ -489,17 +489,32 @@ func (c *Client) websocket(operation string, secret string) (*websocket.Conn, er } func (c *Client) url(elem ...string) string { + // Normalize the URL path := strings.Join(elem, "/") + entries := []string{} + for _, entry := range strings.Split(path, "/") { + if entry == "" { + continue + } + + entries = append(entries, entry) + } + path = strings.Join(entries, "/") + + // Assemble the final URL uri := c.BaseURL + "/" + path + // Aliases may contain a trailing slash if strings.HasPrefix(path, "1.0/images/aliases") { return uri } + // File paths may contain a trailing slash if strings.Contains(path, "?") { return uri } + // Nothing else should contain a trailing slash return strings.TrimSuffix(uri, "/") }
_______________________________________________ lxc-devel mailing list lxc-devel@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-devel