summaryrefslogtreecommitdiffstats
path: root/zellij-server/src/plugins
diff options
context:
space:
mode:
authorAram Drevekenin <aram@poor.dev>2023-06-14 13:44:46 +0200
committerGitHub <noreply@github.com>2023-06-14 13:44:46 +0200
commitf19334754cf1f8e6bd48bb9cdd905a2d5147e30e (patch)
tree6d29a1a05518c109bfc734edf34f3d178051196b /zellij-server/src/plugins
parent59239cc1133179e2825d98b5c2be7c6c3bfdcc9c (diff)
fix(plugins): allow loading relative urls (#2539)
* fix(plugins): allow loading relative urls * style(fmt): rustfmt
Diffstat (limited to 'zellij-server/src/plugins')
-rw-r--r--zellij-server/src/plugins/unit/snapshots/zellij_server__plugins__plugin_tests__start_or_reload_plugin.snap11
-rw-r--r--zellij-server/src/plugins/zellij_exports.rs13
2 files changed, 18 insertions, 6 deletions
diff --git a/zellij-server/src/plugins/unit/snapshots/zellij_server__plugins__plugin_tests__start_or_reload_plugin.snap b/zellij-server/src/plugins/unit/snapshots/zellij_server__plugins__plugin_tests__start_or_reload_plugin.snap
index 173b0ce46..72364a88e 100644
--- a/zellij-server/src/plugins/unit/snapshots/zellij_server__plugins__plugin_tests__start_or_reload_plugin.snap
+++ b/zellij-server/src/plugins/unit/snapshots/zellij_server__plugins__plugin_tests__start_or_reload_plugin.snap
@@ -1,13 +1,16 @@
---
source: zellij-server/src/plugins/./unit/plugin_tests.rs
-assertion_line: 2496
+assertion_line: 2889
expression: "format!(\"{:#?}\", new_tab_event)"
---
Some(
StartOrReloadPluginPane(
- File(
- "/path/to/my/plugin.wasm",
- ),
+ RunPlugin {
+ _allow_exec_host_cmd: false,
+ location: File(
+ "/path/to/my/plugin.wasm",
+ ),
+ },
None,
),
)
diff --git a/zellij-server/src/plugins/zellij_exports.rs b/zellij-server/src/plugins/zellij_exports.rs
index d4153ec8a..08d54c848 100644
--- a/zellij-server/src/plugins/zellij_exports.rs
+++ b/zellij-server/src/plugins/zellij_exports.rs
@@ -26,7 +26,7 @@ use zellij_utils::{
input::{
actions::Action,
command::{RunCommand, RunCommandAction, TerminalAction},
- layout::Layout,
+ layout::{Layout, RunPlugin, RunPluginLocation},
plugins::PluginType,
},
serde,
@@ -946,10 +946,19 @@ fn host_start_or_reload_plugin(env: &ForeignFunctionEnv) {
env.plugin_env.name()
)
};
+ let cwd = std::env::current_dir().unwrap_or_else(|_| PathBuf::from("."));
wasi_read_string(&env.plugin_env.wasi_env)
.and_then(|url| Url::parse(&url).map_err(|e| anyhow!("Failed to parse url: {}", e)))
.and_then(|url| {
- let action = Action::StartOrReloadPlugin(url);
+ RunPluginLocation::parse(url.as_str(), Some(cwd))
+ .map_err(|e| anyhow!("Failed to parse plugin location: {}", e))
+ })
+ .and_then(|run_plugin_location| {
+ let run_plugin = RunPlugin {
+ location: run_plugin_location,
+ _allow_exec_host_cmd: false,
+ };
+ let action = Action::StartOrReloadPlugin(run_plugin);
apply_action!(action, error_msg, env);
Ok(())
})