Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(duckplayer): prevent valid video links from opening in a new tab #2796

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions DuckDuckGo/Tab/TabExtensions/DuckPlayerTabExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,11 @@ extension DuckPlayerTabExtension: NewWindowPolicyDecisionMaker {

func decideNewWindowPolicy(for navigationAction: WKNavigationAction) -> NavigationDecision? {
// if a link was clicked inside duckplayer (like a recommendation)
// and has target=_blank - then we want to prevent a new tab
// opening, and just load it inside the current one instead
// and has target=_blank, or a similar target that would cause a new tab, then we want to prevent that new tab
// from opening, and just load it inside the current one instead
if navigationAction.targetFrame == nil,
navigationAction.safeSourceFrame?.webView?.url?.isDuckPlayer == true,
navigationAction.request.url?.isYoutubeVideoRecommendation == true,
navigationAction.request.url?.isYoutubeVideo == true,
let webView, let url = navigationAction.request.url {
webView.load(URLRequest(url: url))
return .cancel
Expand Down
Loading