@@ -71,12 +71,12 @@ public extension AMQPConnectionConfiguration {
71
71
}
72
72
}
73
73
74
- init ( url: String ) throws {
74
+ init ( url: String , tls : TLSConfiguration ? = nil ) throws {
75
75
guard let url = URL ( string: url) else { throw AMQPConnectionError . invalidUrl }
76
- try self . init ( url: url)
76
+ try self . init ( url: url, tls : tls )
77
77
}
78
-
79
- init ( url: URL ) throws {
78
+
79
+ init ( url: URL , tls : TLSConfiguration ? = nil ) throws {
80
80
guard let scheme = UrlScheme ( rawValue: url. scheme ?? " " ) else { throw AMQPConnectionError . invalidUrlScheme }
81
81
82
82
// there is no such thing as a "" host
@@ -85,7 +85,7 @@ public extension AMQPConnectionConfiguration {
85
85
var vhost = url. path. isEmpty ? nil : String ( url. path. removingPercentEncoding? . dropFirst ( ) ?? " " )
86
86
87
87
// workaround: "/%f" is interpreted as / by URL (this restores %f as /)
88
- if url. absoluteString. hasSuffix ( " %2f " ) {
88
+ if url. absoluteString. lowercased ( ) . hasSuffix ( " %2f " ) {
89
89
if let vh = vhost {
90
90
vhost = vh + " / "
91
91
} else {
@@ -97,7 +97,7 @@ public extension AMQPConnectionConfiguration {
97
97
98
98
switch scheme {
99
99
case . amqp: self = . init( connection: . plain, server: server)
100
- case . amqps: self = . init( connection: . tls( nil , sniServerName: nil ) , server: server)
100
+ case . amqps: self = . init( connection: . tls( tls , sniServerName: nil ) , server: server)
101
101
}
102
102
}
103
103
}
0 commit comments