Skip to content

Conversation

@saseungmin
Copy link
Member

@saseungmin saseungmin commented Aug 4, 2025

  • YouTube logo clicks now open in external browser instead of WebView
  • Add default onShouldStartLoadWithRequest handler to intercept navigation
  • Maintain embed video playback while redirecting external YouTube links
  • core: export MATCH_URL_YOUTUBE regex constant

Summary by CodeRabbit

  • New Features

    • External YouTube links clicked within the embedded video player now open in your device's browser instead of the in-app player, ensuring uninterrupted video playback.
    • Introduced a new regular expression for matching YouTube URLs, now available for use in external integrations.
  • Bug Fixes

    • Prevented the YouTube website from loading inside the embedded player when clicking the YouTube logo.

- YouTube logo clicks now open in external browser instead of WebView
- Add default `onShouldStartLoadWithRequest` handler to intercept navigation
- Maintain embed video playback while redirecting external YouTube links
- core: export `MATCH_URL_YOUTUBE` regex constant
@saseungmin saseungmin self-assigned this Aug 4, 2025
@changeset-bot
Copy link

changeset-bot bot commented Aug 4, 2025

🦋 Changeset detected

Latest commit: c8c4585

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 4 packages
Name Type
@react-native-youtube-bridge/core Patch
react-native-youtube-bridge Patch
@react-native-youtube-bridge/react Patch
@react-native-youtube-bridge/web Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai
Copy link

coderabbitai bot commented Aug 4, 2025

Walkthrough

A new regular expression constant, MATCH_URL_YOUTUBE, is now exported from the core package. The YoutubeView component in the React Native package has been updated to intercept navigation requests in its WebView: YouTube site links now open externally instead of within the embedded player, using a new handler and the exported regex.

Changes

Cohort / File(s) Change Summary
Core Constant Export
packages/core/src/index.ts
Added MATCH_URL_YOUTUBE to the exports from ./constants, making the regex accessible to other modules.
WebView Navigation Handling
packages/react-native-youtube-bridge/src/YoutubeView.tsx
Introduced a handler to intercept WebView navigation; YouTube site links open externally via Linking.openURL, using the new MATCH_URL_YOUTUBE regex.
Changeset Documentation
.changeset/flat-showers-tease.md, .changeset/quick-needles-stay.md
Added documentation for exporting the regex constant and for the new navigation handling in the YouTube bridge WebView component.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant YoutubeView (WebView)
    participant handleShouldStartLoadWithRequest
    participant System Browser

    User->>YoutubeView (WebView): Clicks YouTube logo/link
    YoutubeView (WebView)->>handleShouldStartLoadWithRequest: onShouldStartLoadWithRequest(request)
    handleShouldStartLoadWithRequest->>handleShouldStartLoadWithRequest: Check if URL matches MATCH_URL_YOUTUBE and is not embed
    alt Is YouTube site link
        handleShouldStartLoadWithRequest->>System Browser: Linking.openURL(url)
        handleShouldStartLoadWithRequest-->>YoutubeView (WebView): Return false (prevent navigation)
    else Not a YouTube site link
        handleShouldStartLoadWithRequest-->>YoutubeView (WebView): Return true (allow navigation)
    end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐇
Regex hops out to greet the crowd,
YouTube links now leap, not allowed—
When logos are clicked,
To browsers they're kicked,
The WebView stays calm, unbowed.

Code rabbits cheer with fluffy delight,
For smoother playback, day and night!

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/youtube-external-navigation

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@cloudflare-workers-and-pages
Copy link

Deploying react-native-youtube-bridge-example with  Cloudflare Pages  Cloudflare Pages

Latest commit: c8c4585
Status: ✅  Deploy successful!
Preview URL: https://139e5ebe.react-native-youtube-bridge-example.pages.dev
Branch Preview URL: https://fix-youtube-external-navigat.react-native-youtube-bridge-example.pages.dev

View logs

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
packages/react-native-youtube-bridge/src/YoutubeView.tsx (1)

117-124: Consider error handling for external URL opening.

The logic correctly identifies YouTube URLs that aren't embed URLs and opens them externally. However, consider adding error handling for the Linking.openURL call.

 const handleShouldStartLoadWithRequest = useCallback((request: ShouldStartLoadRequest) => {
   if (MATCH_URL_YOUTUBE.test(request.url) && !request.url.includes('/embed/')) {
-    Linking.openURL(request.url);
+    Linking.openURL(request.url).catch((error) => {
+      console.warn('Failed to open YouTube URL externally:', error);
+    });
     return false;
   }

   return true;
 }, []);
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d02eb41 and c8c4585.

📒 Files selected for processing (4)
  • .changeset/flat-showers-tease.md (1 hunks)
  • .changeset/quick-needles-stay.md (1 hunks)
  • packages/core/src/index.ts (1 hunks)
  • packages/react-native-youtube-bridge/src/YoutubeView.tsx (3 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
packages/react-native-youtube-bridge/src/YoutubeView.tsx (1)
packages/core/src/index.ts (1)
  • MATCH_URL_YOUTUBE (18-18)
🔇 Additional comments (7)
.changeset/flat-showers-tease.md (1)

1-6: LGTM! Changeset accurately documents the regex export.

The changeset correctly documents the addition of the MATCH_URL_YOUTUBE regex constant export with an appropriate patch version bump.

packages/core/src/index.ts (1)

18-18: LGTM! Clean export addition for URL matching functionality.

The addition of MATCH_URL_YOUTUBE to the exports follows the existing pattern and enables the YoutubeView component to access the regex for URL interception.

packages/react-native-youtube-bridge/src/YoutubeView.tsx (4)

2-2: LGTM! Appropriate import addition for external URL opening.

The Linking import is correctly added to enable opening URLs in external browser.


4-4: LGTM! Correct type import for WebView callback.

The ShouldStartLoadRequest type import is necessary for typing the callback parameter.


5-5: LGTM! Import of the exported regex constant.

The MATCH_URL_YOUTUBE import correctly utilizes the newly exported regex from the core package.


169-169: LGTM! Correct WebView prop integration.

The onShouldStartLoadWithRequest prop is correctly wired to the callback function to intercept URL navigation requests.

.changeset/quick-needles-stay.md (1)

1-10: LGTM! Comprehensive changeset documentation.

The changeset accurately documents the fix with clear description of the behavior changes and implementation approach. The patch version bump is appropriate for this bug fix.

@saseungmin saseungmin merged commit 3645311 into main Aug 4, 2025
5 checks passed
@saseungmin saseungmin deleted the fix/youtube-external-navigation branch August 4, 2025 14:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tapping YouTube logo opens full YouTube site inside player instead of launching external app or browser

2 participants