Skip to content

Commit

Permalink
Make sure LSP url is a valid url when switching
Browse files Browse the repository at this point in the history
  • Loading branch information
benthecarman committed Jun 11, 2024
1 parent 10bbc27 commit fb9221f
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions mutiny-core/src/nodemanager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ use std::sync::atomic::{AtomicBool, Ordering};
#[cfg(not(target_arch = "wasm32"))]
use std::time::Instant;
use std::{collections::HashMap, ops::Deref, sync::Arc};
use url::Url;
#[cfg(target_arch = "wasm32")]
use web_time::Instant;

Expand Down Expand Up @@ -2036,8 +2037,14 @@ pub fn create_lsp_config(
) -> Result<Option<LspConfig>, MutinyError> {
match (lsp_url.clone(), lsp_connection_string.clone()) {
(Some(lsp_url), None) => {
if !lsp_url.is_empty() {
Ok(Some(LspConfig::new_voltage_flow(lsp_url)))
let trimmed = lsp_url.trim().to_string();
if !trimmed.is_empty() {
// make sure url is valid
if Url::parse(&trimmed).is_err() {
return Err(MutinyError::InvalidArgumentsError);
}

Ok(Some(LspConfig::new_voltage_flow(trimmed)))
} else {
Ok(None)
}
Expand Down

0 comments on commit fb9221f

Please sign in to comment.