[lxc-devel] [lxd/master] client: Strip trailing slashes in URLs
stgraber on Github
lxc-bot at linuxcontainers.org
Tue Jan 29 18:29:15 UTC 2019
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 370 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20190129/b775c1ff/attachment.bin>
-------------- next part --------------
From d7ad750e892dfe0396b870d597a225f4c2c45212 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Tue, 29 Jan 2019 13:28:08 -0500
Subject: [PATCH] client: Strip trailing slashes in URLs
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Closes #5438
Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
client/connection.go | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/client/connection.go b/client/connection.go
index b300cae198..90875debd6 100644
--- a/client/connection.go
+++ b/client/connection.go
@@ -5,6 +5,7 @@ import (
"net/url"
"os"
"path/filepath"
+ "strings"
"github.com/lxc/lxd/shared/logger"
"github.com/lxc/lxd/shared/simplestreams"
@@ -60,6 +61,9 @@ type ConnectionArgs struct {
func ConnectLXD(url string, args *ConnectionArgs) (ContainerServer, error) {
logger.Debugf("Connecting to a remote LXD over HTTPs")
+ // Cleanup URL
+ url = strings.TrimSuffix(url, "/")
+
return httpsLXD(url, args)
}
@@ -123,6 +127,9 @@ func ConnectLXDUnix(path string, args *ConnectionArgs) (ContainerServer, error)
func ConnectPublicLXD(url string, args *ConnectionArgs) (ImageServer, error) {
logger.Debugf("Connecting to a remote public LXD over HTTPs")
+ // Cleanup URL
+ url = strings.TrimSuffix(url, "/")
+
return httpsLXD(url, args)
}
@@ -132,6 +139,9 @@ func ConnectPublicLXD(url string, args *ConnectionArgs) (ImageServer, error) {
func ConnectSimpleStreams(url string, args *ConnectionArgs) (ImageServer, error) {
logger.Debugf("Connecting to a remote simplestreams server")
+ // Cleanup URL
+ url = strings.TrimSuffix(url, "/")
+
// Use empty args if not specified
if args == nil {
args = &ConnectionArgs{}
More information about the lxc-devel
mailing list