fix(uriproxy): if uri is ready just pass it thru
This commit is contained in:
parent
aca757a266
commit
fa3f0f853a
1 changed files with 5 additions and 0 deletions
|
@ -21,6 +21,10 @@ impl AsRef<str> for UriClass {
|
||||||
|
|
||||||
/// unpack uri in id if valid, otherwise compose full uri with "{base}/{entity}/{id}"
|
/// unpack uri in id if valid, otherwise compose full uri with "{base}/{entity}/{id}"
|
||||||
pub fn uri(base: &str, entity: UriClass, id: &str) -> String {
|
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 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(bytes) = base64::prelude::BASE64_URL_SAFE_NO_PAD.decode(id.replacen('+', "", 1)) {
|
||||||
if let Ok(uri) = std::str::from_utf8(&bytes) {
|
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)
|
format!("{}/{}/{}", base, entity.as_ref(), id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue