fix: parse VPN URL to support custom port

Related: #404
This commit is contained in:
Kevin Yue committed 2025-07-08 23:32:54 +08:00
1 parent e1eb9e20f1
commit 11925a372d
2 files changed
+5 -11

No files matched your search

+1 -1
View File
@@ -122,7 +122,7 @@ impl Cli {
let browser = self let browser = self
.browser .browser
.as_deref() .as_deref()
.or_else(|| self.default_browser.then_some("default")); .or_else(|| self.default_browser.then(|| "default"));
#[cfg(not(feature = "webview-auth"))] #[cfg(not(feature = "webview-auth"))]
let browser = self.browser.as_deref().or(Some("default")); let browser = self.browser.as_deref().or(Some("default"));
+4 -10
View File
@@ -36,13 +36,7 @@ pub struct Vpn {
impl Vpn { impl Vpn {
pub fn builder(server: &str, cookie: &str) -> VpnBuilder { pub fn builder(server: &str, cookie: &str) -> VpnBuilder {
// prepend "https://" to the server if it doesn't already start with it VpnBuilder::new(server, cookie)
let server = if server.starts_with("https://") {
server.to_string()
} else {
format!("https://{}", server)
};
VpnBuilder::new(server, cookie.to_string())
} }
pub fn connect(&self, on_connected: impl FnOnce() + 'static + Send + Sync) -> i32 { pub fn connect(&self, on_connected: impl FnOnce() + 'static + Send + Sync) -> i32 {
@@ -140,10 +134,10 @@ pub struct VpnBuilder {
} }
impl VpnBuilder { impl VpnBuilder {
fn new(server: String, cookie: String) -> Self { fn new(server: &str, cookie: &str) -> Self {
Self { Self {
server, server: server.to_string(),
cookie, cookie: cookie.to_string(),
script: None, script: None,
interface: None, interface: None,