diff --git a/DuckDuckGo/TabViewController.swift b/DuckDuckGo/TabViewController.swift index 6cc79cf3d9..2c5e3fb563 100644 --- a/DuckDuckGo/TabViewController.swift +++ b/DuckDuckGo/TabViewController.swift @@ -724,23 +724,30 @@ class TabViewController: UIViewController { func goBack() { dismissJSAlertIfNeeded() - if let handler = youtubeNavigationHandler { + if let url = url, url.isDuckPlayer, let handler = youtubeNavigationHandler { handler.goBack(webView: webView) chromeDelegate?.omniBar.resignFirstResponder() - } else { - if isError { - hideErrorMessage() - url = webView.url - onWebpageDidStartLoading(httpsForced: false) - onWebpageDidFinishLoading() - } else if webView.canGoBack { - webView.goBack() - chromeDelegate?.omniBar.resignFirstResponder() - } else if openingTab != nil { - delegate?.tabDidRequestClose(self) - } + return + } + + if isError { + hideErrorMessage() + url = webView.url + onWebpageDidStartLoading(httpsForced: false) + onWebpageDidFinishLoading() + return + } + + if webView.canGoBack { + webView.goBack() + chromeDelegate?.omniBar.resignFirstResponder() + return } + if openingTab != nil { + delegate?.tabDidRequestClose(self) + } + } func goForward() {