Skip to content

Commit 1d1cea9

Browse files
committed
Avoid infinite loop if the initial url happens to be the nonce retrieval path
1 parent 4282f36 commit 1d1cea9

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

WooCommerce/Classes/Authentication/AuthenticatedWebViewController.swift

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,14 @@ private extension AuthenticatedWebViewController {
105105

106106
webView.publisher(for: \.url)
107107
.sink { [weak self] url in
108-
if url?.absoluteString.contains(WKWebView.wporgNoncePath) == true {
109-
self?.loadContent()
108+
guard let self else { return }
109+
let initialURL = self.viewModel.initialURL
110+
// avoids infinite loop if the initial url happens to be the nonce retrieval path.
111+
if url?.absoluteString.contains(WKWebView.wporgNoncePath) == true,
112+
initialURL?.absoluteString.contains(WKWebView.wporgNoncePath) != true {
113+
self.loadContent()
110114
} else {
111-
self?.viewModel.handleRedirect(for: url)
115+
self.viewModel.handleRedirect(for: url)
112116
}
113117
}
114118
.store(in: &subscriptions)

0 commit comments

Comments
 (0)