From fa3f0f853a65d47ae9a71efaa98a35e22f152ba5 Mon Sep 17 00:00:00 2001 From: alemi Date: Mon, 20 May 2024 07:42:58 +0200 Subject: [PATCH] fix(uriproxy): if uri is ready just pass it thru --- uriproxy/src/lib.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/uriproxy/src/lib.rs b/uriproxy/src/lib.rs index 6c35ff2..59a0773 100644 --- a/uriproxy/src/lib.rs +++ b/uriproxy/src/lib.rs @@ -21,6 +21,10 @@ impl AsRef for UriClass { /// unpack uri in id if valid, otherwise compose full uri with "{base}/{entity}/{id}" pub fn uri(base: &str, entity: UriClass, id: &str) -> String { + if id.starts_with("https://") || id.starts_with("http://") { + return id.to_string(); + } + if id.starts_with('+') { // ready-to-use base64-encoded id if let Ok(bytes) = base64::prelude::BASE64_URL_SAFE_NO_PAD.decode(id.replacen('+', "", 1)) { if let Ok(uri) = std::str::from_utf8(&bytes) { @@ -28,6 +32,7 @@ pub fn uri(base: &str, entity: UriClass, id: &str) -> String { } } } + format!("{}/{}/{}", base, entity.as_ref(), id) }