fix: urlencode reconstructed urls

ouch wordpress, thank you but clean your urls pls
This commit is contained in:
əlemi 2024-05-13 14:41:37 +02:00
parent 8f806b1bd6
commit 025981228d
Signed by: alemi
GPG key ID: A4895B84D311642C
3 changed files with 6 additions and 3 deletions

1
Cargo.lock generated
View file

@ -4489,6 +4489,7 @@ dependencies = [
"tower-http",
"tracing",
"tracing-subscriber",
"url",
"uuid",
]

View file

@ -26,10 +26,12 @@ serde = { version = "1", features = ["derive"] }
serde_json = "1"
serde_default = "0.1"
serde-inline-default = "0.2"
toml = "0.8"
mdhtml = { path = "mdhtml", features = ["markdown"] }
jrd = "0.1"
tracing = "0.1"
tracing-subscriber = "0.3"
url = "2.5"
clap = { version = "4.5", features = ["derive"] }
futures = "0.3"
tokio = { version = "1.35", features = ["full"] } # TODO slim this down
@ -46,7 +48,6 @@ sea-orm-migration = { version = "0.12", optional = true }
mastodon-async-entities = { version = "1.1.0", optional = true }
time = { version = "0.3", features = ["serde"], optional = true }
async-recursion = "1.1"
toml = "0.8.12"
[features]
default = ["migrations", "cli"]

View file

@ -105,10 +105,11 @@ impl Context {
if id.starts_with("http") { // ready-to-use id
id
} else if id.starts_with('+') { // compacted id
id
let reconstructed = id
.replace('@', "/")
.replace("//", "/@") // oops my method sucks!! TODO
.replacen('+', "https://", 1)
.replacen('+', "https://", 1);
url::form_urlencoded::byte_serialize(reconstructed.as_bytes()).collect()
} else { // bare local id
format!("{}{}/{}/{}", self.0.protocol, self.0.domain, entity, id)
}