Skip to content

Commit 5bb1faa

Browse files
committed
Force https for jetpack sites
1 parent 06e16dd commit 5bb1faa

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

Modules/Sources/Networking/Model/Site.swift

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,20 @@ public enum SiteVisibility: Int, Codable, GeneratedFakeable {
333333
///
334334
public extension Site {
335335

336+
private var jetpackCanonicalURL: String {
337+
guard isJetpackConnected,
338+
let originalURL = URL(string: url),
339+
originalURL.scheme?.lowercased() == "http"
340+
else {
341+
return url
342+
}
343+
344+
var components = URLComponents(url: originalURL, resolvingAgainstBaseURL: false)
345+
components?.scheme = "https"
346+
347+
return components?.string ?? url
348+
}
349+
336350
/// Returns the TimeZone using the gmtOffset
337351
///
338352
var siteTimezone: TimeZone {
@@ -347,7 +361,7 @@ public extension Site {
347361
}
348362

349363
func toJetpackSite() -> JetpackSite {
350-
JetpackSite(siteID: siteID, siteAddress: url, applicationPasswordAvailable: applicationPasswordAvailable)
364+
JetpackSite(siteID: siteID, siteAddress: jetpackCanonicalURL, applicationPasswordAvailable: applicationPasswordAvailable)
351365
}
352366
}
353367

0 commit comments

Comments
 (0)