Skip to main content

Mountain/IPC/WindServiceHandlers/Navigation/
LabelGetBase.rs

1
2//! Last path segment (filename + extension) of a URI. Used by
3//! the editor tabs and breadcrumbs where only the file's name
4//! is wanted, not its full path.
5
6use serde_json::Value;
7
8pub async fn Fn(Arguments:Vec<Value>) -> Result<Value, String> {
9	let Uri = Arguments
10		.first()
11		.and_then(|V| V.as_str())
12		.ok_or("label:getBase requires uri".to_string())?;
13
14	let Base = Uri.split('/').next_back().unwrap_or(Uri);
15
16	Ok(Value::String(Base.to_owned()))
17}