Skip to content

feat: Adjust WebView2 to handle absolute and relative URIs - #22136

Merged
agneszitte merged 3 commits into
masterfrom
dev/doti/webview-absolute-url
Feb 28, 2026
Merged

agneszitte merged 3 commits into
masterfrom
dev/doti/webview-absolute-url

Conversation

@morning4coffe-dev

Copy link
Copy Markdown
Member

GitHub Issue: closes #22115

PR Type:

  • 🐞 Bugfix

What is the current behavior? 🤔

What is the new behavior? 🚀

PR Checklist ✅

Please check if your PR fulfills the following requirements:

Other information ℹ️

Copilot AI review requested due to automatic review settings December 14, 2025 14:24

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a bug in WebView2 where calling ToString() on a relative URI causes an InvalidOperationException. The fix updates the code to use AbsoluteUri for absolute URIs and OriginalString for relative URIs, ensuring proper handling of both URI types when navigating.

Key Changes:

  • Updated URI-to-string conversion logic to check IsAbsoluteUri before deciding between AbsoluteUri and OriginalString
  • Applied the fix consistently across WebView2 property changed handler and CoreWebView2 navigation methods

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/Uno.UI/UI/Xaml/Controls/WebView/WebView2/WebView2.Properties.cs Updated Source property changed handler to handle both absolute and relative URIs by checking IsAbsoluteUri before converting to string
src/Uno.UI/UI/Xaml/Controls/WebView/Core/CoreWebView2.cs Applied the same URI handling logic to Navigate and NavigateWithHttpRequestMessage methods for consistency

@unodevops

Copy link
Copy Markdown
Contributor

@unodevops

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

@unodevops

Copy link
Copy Markdown
Contributor

@unodevops

Copy link
Copy Markdown
Contributor

@ajpinedam ajpinedam left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Change looks good. Could a test be added to validate this new behaviour?

@morning4coffe-dev morning4coffe-dev self-assigned this Jan 15, 2026
@agneszitte

Copy link
Copy Markdown
Member

@MartinZikmund, @morning4coffe-dev I will let you follow up for this PR please

@unodevops

Copy link
Copy Markdown
Contributor

@morning4coffe-dev

Copy link
Copy Markdown
Member Author

@agneszitte Waiting on master to pass now

@agneszitte
agneszitte disabled auto-merge February 28, 2026 00:40
@agneszitte
agneszitte merged commit bfdd078 into master Feb 28, 2026
40 checks passed
@agneszitte
agneszitte deleted the dev/doti/webview-absolute-url branch February 28, 2026 01:34
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators May 1, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[WebView2] WebView2 SourceProperty uses Uri.ToString(): potential Bug source and pre-escaping expectations for consumers missing in Docs

6 participants