fix(web): show uncloaked urls
This commit is contained in:
parent
7ae1d02c02
commit
d0138c5fc0
3 changed files with 10 additions and 1 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -4876,6 +4876,7 @@ name = "upub-web"
|
|||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"apb",
|
||||
"base64 0.22.1",
|
||||
"chrono",
|
||||
"console_error_panic_hook",
|
||||
"cookie",
|
||||
|
|
|
@ -14,6 +14,7 @@ repository = "https://git.alemi.dev/upub.git"
|
|||
[dependencies]
|
||||
lazy_static = "1.4"
|
||||
cookie = "0.18"
|
||||
base64 = "0.22"
|
||||
tracing = "0.1"
|
||||
tracing-subscriber = "0.3"
|
||||
tracing-subscriber-wasm = "0.1"
|
||||
|
|
|
@ -1,8 +1,14 @@
|
|||
use leptos::*;
|
||||
use crate::{prelude::*, URL_SENSITIVE};
|
||||
|
||||
use base64::prelude::*;
|
||||
use apb::{field::OptionalString, Document, Object};
|
||||
|
||||
fn uncloak(txt: Option<&str>) -> Option<String> {
|
||||
let decoded = BASE64_URL_SAFE.decode(txt?).ok()?;
|
||||
Some(std::str::from_utf8(&decoded).ok()?.to_string())
|
||||
}
|
||||
|
||||
#[component]
|
||||
pub fn Attachment(
|
||||
object: serde_json::Value,
|
||||
|
@ -12,6 +18,7 @@ pub fn Attachment(
|
|||
let config = use_context::<Signal<crate::Config>>().expect("missing config context");
|
||||
let (expand, set_expand) = create_signal(false);
|
||||
let href = object.url().id().str().unwrap_or_default();
|
||||
let uncloaked = uncloak(href.split('/').last()).unwrap_or_default();
|
||||
let media_type = object.media_type()
|
||||
.unwrap_or("link") // TODO make it an Option rather than defaulting to link everywhere
|
||||
.to_string();
|
||||
|
@ -78,7 +85,7 @@ pub fn Attachment(
|
|||
view! {
|
||||
<p class="mt-s mb-s">
|
||||
<a title={href.clone()} href={href.clone()} rel="noreferrer nofollow" target="_blank">
|
||||
{Uri::pretty(&href, 50)}
|
||||
{Uri::pretty(&uncloaked, 50)}
|
||||
</a>
|
||||
</p>
|
||||
}.into_view(),
|
||||
|
|
Loading…
Reference in a new issue