Repository navigation
feat: Adjust WebView2 to handle absolute and relative URIs - #22136
Conversation
There was a problem hiding this comment.
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
IsAbsoluteUribefore deciding betweenAbsoluteUriandOriginalString - 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 |
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-22136/wasm-skia-net9/index.html |
|
🤖 Your Docs stage site is ready! Visit it here: https://unodocsprstaging.z13.web.core.windows.net/pr-22136/docs/index.html |
Co-authored-by: Copilot <[email protected]>
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-22136/wasm-skia-net9/index.html |
|
🤖 Your Docs stage site is ready! Visit it here: https://unodocsprstaging.z13.web.core.windows.net/pr-22136/docs/index.html |
ajpinedam
left a comment
There was a problem hiding this comment.
Change looks good. Could a test be added to validate this new behaviour?
|
@MartinZikmund, @morning4coffe-dev I will let you follow up for this PR please |
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-22136/wasm-skia-net9/index.html |
|
@agneszitte Waiting on master to pass now |
GitHub Issue: closes #22115
PR Type:
What is the current behavior? 🤔
What is the new behavior? 🚀
PR Checklist ✅
Please check if your PR fulfills the following requirements:
Screenshots Compare Test Runresults.Other information ℹ️