forked from alemi/upub
fix: urlencode reconstructed urls
ouch wordpress, thank you but clean your urls pls
This commit is contained in:
parent
8f806b1bd6
commit
025981228d
3 changed files with 6 additions and 3 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -4489,6 +4489,7 @@ dependencies = [
|
||||||
"tower-http",
|
"tower-http",
|
||||||
"tracing",
|
"tracing",
|
||||||
"tracing-subscriber",
|
"tracing-subscriber",
|
||||||
|
"url",
|
||||||
"uuid",
|
"uuid",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -26,10 +26,12 @@ serde = { version = "1", features = ["derive"] }
|
||||||
serde_json = "1"
|
serde_json = "1"
|
||||||
serde_default = "0.1"
|
serde_default = "0.1"
|
||||||
serde-inline-default = "0.2"
|
serde-inline-default = "0.2"
|
||||||
|
toml = "0.8"
|
||||||
mdhtml = { path = "mdhtml", features = ["markdown"] }
|
mdhtml = { path = "mdhtml", features = ["markdown"] }
|
||||||
jrd = "0.1"
|
jrd = "0.1"
|
||||||
tracing = "0.1"
|
tracing = "0.1"
|
||||||
tracing-subscriber = "0.3"
|
tracing-subscriber = "0.3"
|
||||||
|
url = "2.5"
|
||||||
clap = { version = "4.5", features = ["derive"] }
|
clap = { version = "4.5", features = ["derive"] }
|
||||||
futures = "0.3"
|
futures = "0.3"
|
||||||
tokio = { version = "1.35", features = ["full"] } # TODO slim this down
|
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 }
|
mastodon-async-entities = { version = "1.1.0", optional = true }
|
||||||
time = { version = "0.3", features = ["serde"], optional = true }
|
time = { version = "0.3", features = ["serde"], optional = true }
|
||||||
async-recursion = "1.1"
|
async-recursion = "1.1"
|
||||||
toml = "0.8.12"
|
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["migrations", "cli"]
|
default = ["migrations", "cli"]
|
||||||
|
|
|
@ -105,10 +105,11 @@ impl Context {
|
||||||
if id.starts_with("http") { // ready-to-use id
|
if id.starts_with("http") { // ready-to-use id
|
||||||
id
|
id
|
||||||
} else if id.starts_with('+') { // compacted id
|
} else if id.starts_with('+') { // compacted id
|
||||||
id
|
let reconstructed = id
|
||||||
.replace('@', "/")
|
.replace('@', "/")
|
||||||
.replace("//", "/@") // oops my method sucks!! TODO
|
.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
|
} else { // bare local id
|
||||||
format!("{}{}/{}/{}", self.0.protocol, self.0.domain, entity, id)
|
format!("{}{}/{}/{}", self.0.protocol, self.0.domain, entity, id)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue