Skip to content

Commit 6a64134

Browse files
authored
Merge pull request #42 from xtremekforever/feature/amqp-connection-configuration
Small quality of life updates for AMQPConnectionConfiguration
2 parents 4dc6597 + d38ac5e commit 6a64134

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

Sources/AMQPClient/AMQPConnectionConfiguration.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,12 @@ public extension AMQPConnectionConfiguration {
7171
}
7272
}
7373

74-
init(url: String) throws {
74+
init(url: String, tls: TLSConfiguration? = nil) throws {
7575
guard let url = URL(string: url) else { throw AMQPConnectionError.invalidUrl }
76-
try self.init(url: url)
76+
try self.init(url: url, tls: tls)
7777
}
78-
79-
init(url: URL) throws {
78+
79+
init(url: URL, tls: TLSConfiguration? = nil) throws {
8080
guard let scheme = UrlScheme(rawValue: url.scheme ?? "") else { throw AMQPConnectionError.invalidUrlScheme }
8181

8282
// there is no such thing as a "" host
@@ -85,7 +85,7 @@ public extension AMQPConnectionConfiguration {
8585
var vhost = url.path.isEmpty ? nil : String(url.path.removingPercentEncoding?.dropFirst() ?? "")
8686

8787
// workaround: "/%f" is interpreted as / by URL (this restores %f as /)
88-
if url.absoluteString.hasSuffix("%2f") {
88+
if url.absoluteString.lowercased().hasSuffix("%2f") {
8989
if let vh = vhost {
9090
vhost = vh + "/"
9191
} else {
@@ -97,7 +97,7 @@ public extension AMQPConnectionConfiguration {
9797

9898
switch scheme {
9999
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)
101101
}
102102
}
103103
}

0 commit comments

Comments
 (0)