Fix "Post url contains non-ASCII characters" error (#479)
This commit is contained in:
parent
7f5bfc04b3
commit
90828cc71c
3 changed files with 4 additions and 1 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -596,6 +596,7 @@ dependencies = [
|
||||||
"futures-lite",
|
"futures-lite",
|
||||||
"hyper",
|
"hyper",
|
||||||
"hyper-rustls",
|
"hyper-rustls",
|
||||||
|
"percent-encoding",
|
||||||
"regex",
|
"regex",
|
||||||
"route-recognizer",
|
"route-recognizer",
|
||||||
"rust-embed",
|
"rust-embed",
|
||||||
|
|
|
@ -18,6 +18,7 @@ cookie = "0.16.0"
|
||||||
futures-lite = "1.12.0"
|
futures-lite = "1.12.0"
|
||||||
hyper = { version = "0.14.18", features = ["full"] }
|
hyper = { version = "0.14.18", features = ["full"] }
|
||||||
hyper-rustls = "0.23.0"
|
hyper-rustls = "0.23.0"
|
||||||
|
percent-encoding = "2.1.0"
|
||||||
route-recognizer = "0.3.1"
|
route-recognizer = "0.3.1"
|
||||||
serde_json = "1.0.81"
|
serde_json = "1.0.81"
|
||||||
tokio = { version = "1.18.2", features = ["full"] }
|
tokio = { version = "1.18.2", features = ["full"] }
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
use cached::proc_macro::cached;
|
use cached::proc_macro::cached;
|
||||||
use futures_lite::{future::Boxed, FutureExt};
|
use futures_lite::{future::Boxed, FutureExt};
|
||||||
use hyper::{body::Buf, client, Body, Request, Response, Uri};
|
use hyper::{body::Buf, client, Body, Request, Response, Uri};
|
||||||
|
use percent_encoding::{percent_encode, CONTROLS};
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
use std::result::Result;
|
use std::result::Result;
|
||||||
|
|
||||||
|
@ -90,7 +91,7 @@ fn request(url: String, quarantine: bool) -> Boxed<Result<Response<Body>, String
|
||||||
.headers()
|
.headers()
|
||||||
.get("Location")
|
.get("Location")
|
||||||
.map(|val| {
|
.map(|val| {
|
||||||
let new_url = val.to_str().unwrap_or_default();
|
let new_url = percent_encode(val.as_bytes(), CONTROLS).to_string();
|
||||||
format!("{}{}raw_json=1", new_url, if new_url.contains('?') { "&" } else { "?" })
|
format!("{}{}raw_json=1", new_url, if new_url.contains('?') { "&" } else { "?" })
|
||||||
})
|
})
|
||||||
.unwrap_or_default()
|
.unwrap_or_default()
|
||||||
|
|
Loading…
Reference in a new issue