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 empty string bug (fix: #833) #836

Merged
merged 2 commits into from
Jan 8, 2023
Merged
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions .changes/check-for-empty-init-scripts.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"wry": "patch"
---

Ensures that the script passed to `.with_initialization_script("here")` is not empty.
4 changes: 3 additions & 1 deletion src/webview/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,9 @@ impl<'a> WebViewBuilder<'a> {
/// - **Android:** The Android WebView does not provide an API for initialization scripts,
/// so we prepend them to each HTML head. They are only implemented on custom protocol URLs.
pub fn with_initialization_script(mut self, js: &str) -> Self {
self.webview.initialization_scripts.push(js.to_string());
if !js.is_empty() {
self.webview.initialization_scripts.push(js.to_string());
}
self
}

Expand Down