Compare commits
No commits in common. "b6e48025fbda6f91b5603f5c660cda7dd1017186" and "bf86e44b0024040b8122fc4a222bf04f9b510c0b" have entirely different histories.
b6e48025fb
...
bf86e44b00
3 changed files with 5 additions and 10 deletions
|
@ -39,10 +39,8 @@ pub fn uri(base: &str, entity: UriClass, id: &str) -> String {
|
||||||
/// decompose local id constructed by uri() fn
|
/// decompose local id constructed by uri() fn
|
||||||
pub fn decompose_id(full_id: &str) -> String {
|
pub fn decompose_id(full_id: &str) -> String {
|
||||||
full_id // https://example.org/users/test/followers/page?offset=42
|
full_id // https://example.org/users/test/followers/page?offset=42
|
||||||
.replace("https://", "")
|
.split('/') // ['https:', '', 'example.org', 'users', 'test', 'followers', 'page?offset=42' ]
|
||||||
.replace("http://", "")
|
.nth(4) // 'test'
|
||||||
.split('/') // ['example.org', 'users', 'test', 'followers', 'page?offset=42' ]
|
|
||||||
.nth(2) // 'test'
|
|
||||||
.unwrap_or("")
|
.unwrap_or("")
|
||||||
.to_string()
|
.to_string()
|
||||||
}
|
}
|
||||||
|
|
|
@ -118,12 +118,10 @@ impl Uri {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn short(url: &str) -> String {
|
pub fn short(url: &str) -> String {
|
||||||
if url.starts_with(URL_BASE) || url.starts_with('/') {
|
if url.starts_with(URL_BASE) {
|
||||||
uriproxy::decompose_id(url)
|
uriproxy::decompose_id(url)
|
||||||
} else if url.starts_with("https://") || url.starts_with("http") {
|
|
||||||
uriproxy::compact_id(url)
|
|
||||||
} else {
|
} else {
|
||||||
url.to_string()
|
uriproxy::compact_id(url)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,8 +28,7 @@ pub fn UserPage(tl: Timeline) -> impl IntoView {
|
||||||
.cloned()
|
.cloned()
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
let uid = uriproxy::uri(URL_BASE, uriproxy::UriClass::User, &id);
|
let uid = uriproxy::uri(URL_BASE, uriproxy::UriClass::User, &id);
|
||||||
let _uid = uid.clone();
|
let actor = create_local_resource(move || params.get().get("id").cloned().unwrap_or_default(), move |id| {
|
||||||
let actor = create_local_resource(move || _uid.clone(), move |id| {
|
|
||||||
async move {
|
async move {
|
||||||
match CACHE.get(&Uri::full(U::User, &id)) {
|
match CACHE.get(&Uri::full(U::User, &id)) {
|
||||||
Some(x) => Some(x.clone()),
|
Some(x) => Some(x.clone()),
|
||||||
|
|
Loading…
Reference in a new issue