forked from alemi/upub
fix(uriproxy): dont use padding
This commit is contained in:
parent
c6602d0669
commit
d7ebb2f95e
1 changed files with 2 additions and 2 deletions
|
@ -22,7 +22,7 @@ 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('+') { // 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.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) {
|
||||||
return uri.to_string();
|
return uri.to_string();
|
||||||
}
|
}
|
||||||
|
@ -42,6 +42,6 @@ pub fn decompose_id(full_id: &str) -> String {
|
||||||
|
|
||||||
/// encode with base64 remote url and prefix it with +
|
/// encode with base64 remote url and prefix it with +
|
||||||
pub fn compact_id(uri: &str) -> String {
|
pub fn compact_id(uri: &str) -> String {
|
||||||
let encoded = base64::prelude::BASE64_URL_SAFE.encode(uri.as_bytes());
|
let encoded = base64::prelude::BASE64_URL_SAFE_NO_PAD.encode(uri.as_bytes());
|
||||||
format!("+{encoded}")
|
format!("+{encoded}")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue