From 0d2c279f931ae0b6b6f8e48e45b7e0f394e85a39 Mon Sep 17 00:00:00 2001 From: alemi Date: Mon, 15 Apr 2024 23:11:52 +0200 Subject: [PATCH] docs(web): documented web_uri and api_uri --- web/src/lib.rs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/web/src/lib.rs b/web/src/lib.rs index 5d2aa7ad..74d936ed 100644 --- a/web/src/lib.rs +++ b/web/src/lib.rs @@ -15,19 +15,31 @@ struct LoginForm { password: String, } +/// convert url id to valid frontend view id +/// accepts: +/// - https://my.domain.net/users/root +/// - https://other.domain.net/unexpected/path/root +/// - +other.domain.net@users@root +/// - root fn web_uri(kind: &str, url: &str) -> String { if url.starts_with(URL_BASE) { format!("/web/{kind}/{}", url.split('/').last().unwrap_or_default()) } else { - format!("/web/{kind}/+{}", url.replace("https://", "").replace('/', "@")) + format!("/web/{kind}/{}", url.replace("https://", "+").replace('/', "@")) } } +/// convert url id to valid backend api id +/// accepts: +/// - https://my.domain.net/users/root +/// - https://other.domain.net/unexpected/path/root +/// - +other.domain.net@users@root +/// - root fn api_uri(kind: &str, url: &str) -> String { if url.starts_with(URL_BASE) { url.to_string() } else { - format!("{URL_BASE}/{kind}/+{}", url.replace("https://", "").replace('/', "@")) + format!("{URL_BASE}/{kind}/{}", url.replace("https://", "+").replace('/', "@")) } }