Skip to content

Commit

Permalink
fix empty string bug (fix: #833) (#836)
Browse files Browse the repository at this point in the history
* fix empty string bug

* Push to trigger CI/CD
  • Loading branch information
TheBrenny committed Jan 8, 2023
1 parent ad168a2 commit ceb209e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changes/check-for-empty-init-scripts.md
@@ -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
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

0 comments on commit ceb209e

Please sign in to comment.