Skip to content

Commit 4fe4bc2

Browse files
fix: refactor getUrl method to use URL appendingPathComponent
1 parent 1c33f0d commit 4fe4bc2

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

Sources/CMAB/CmabClient.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,11 @@ class DefaultCmabClient: CmabClient {
101101
}
102102

103103
func getUrl(ruleId: String) -> URL? {
104-
let urlString = predictionEndpoint.hasSuffix("/") ? "predictionEndpoint\(ruleId)" : "\(predictionEndpoint)/\(ruleId)"
105-
guard let url = URL(string: urlString) else {
104+
guard let baseURL = URL(string: predictionEndpoint) else {
106105
self.logger.e("Invalid CMAB endpoint")
107106
return nil
108107
}
109-
return url
108+
return baseURL.appendingPathComponent(ruleId)
110109
}
111110

112111
private func doFetchWithRetry(

0 commit comments

Comments
 (0)