mirror of
https://github.com/clash-verge-rev/clash-verge-rev
synced 2025-05-05 09:03:43 +08:00
feat: Use url path name as fallback subscription name (#255)
This commit is contained in:
parent
e970880059
commit
0ae96918e9
@ -261,7 +261,9 @@ impl PrfItem {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
None => None,
|
None => Some(
|
||||||
|
crate::utils::help::get_last_part_and_decode(url).unwrap_or("Remote File".into()),
|
||||||
|
),
|
||||||
};
|
};
|
||||||
let option = match update_interval {
|
let option = match update_interval {
|
||||||
Some(val) => Some(PrfOption {
|
Some(val) => Some(PrfOption {
|
||||||
|
@ -80,6 +80,19 @@ pub fn parse_str<T: FromStr>(target: &str, key: &str) -> Option<T> {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// get the last part of the url, if not found, return empty string
|
||||||
|
pub fn get_last_part_and_decode(url: &str) -> Option<String> {
|
||||||
|
let path = url.split('?').next().unwrap_or(""); // Splits URL and takes the path part
|
||||||
|
let segments: Vec<&str> = path.split('/').collect();
|
||||||
|
let last_segment = segments.last()?;
|
||||||
|
|
||||||
|
Some(
|
||||||
|
percent_encoding::percent_decode_str(last_segment)
|
||||||
|
.decode_utf8_lossy()
|
||||||
|
.to_string(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
/// open file
|
/// open file
|
||||||
/// use vscode by default
|
/// use vscode by default
|
||||||
pub fn open_file(app: tauri::AppHandle, path: PathBuf) -> Result<()> {
|
pub fn open_file(app: tauri::AppHandle, path: PathBuf) -> Result<()> {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user