mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-06-16 23:56:37 +00:00
Rm unused percent_encode_http_url_path
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
parent
1350ac342f
commit
ffe47d30c6
1 changed files with 1 additions and 21 deletions
|
@ -2,33 +2,13 @@ use std::{future::Future, sync::OnceLock, time::Duration};
|
|||
|
||||
use binstalk_downloader::remote::{self, header::HeaderMap, StatusCode, Url};
|
||||
use compact_str::CompactString;
|
||||
use percent_encoding::{
|
||||
percent_decode_str, utf8_percent_encode, AsciiSet, PercentEncode, CONTROLS,
|
||||
};
|
||||
use percent_encoding::percent_decode_str;
|
||||
use serde::{de::DeserializeOwned, Deserialize, Serialize};
|
||||
use serde_json::to_string as to_json_string;
|
||||
use tracing::debug;
|
||||
|
||||
use super::{GhApiError, GhGraphQLErrors};
|
||||
|
||||
pub(super) fn percent_encode_http_url_path(path: &str) -> PercentEncode<'_> {
|
||||
/// https://url.spec.whatwg.org/#fragment-percent-encode-set
|
||||
const FRAGMENT: &AsciiSet = &CONTROLS.add(b' ').add(b'"').add(b'<').add(b'>').add(b'`');
|
||||
|
||||
/// https://url.spec.whatwg.org/#path-percent-encode-set
|
||||
const PATH: &AsciiSet = &FRAGMENT.add(b'#').add(b'?').add(b'{').add(b'}');
|
||||
|
||||
const PATH_SEGMENT: &AsciiSet = &PATH.add(b'/').add(b'%');
|
||||
|
||||
// The backslash (\) character is treated as a path separator in special URLs
|
||||
// so it needs to be additionally escaped in that case.
|
||||
//
|
||||
// http is considered to have special path.
|
||||
const SPECIAL_PATH_SEGMENT: &AsciiSet = &PATH_SEGMENT.add(b'\\');
|
||||
|
||||
utf8_percent_encode(path, SPECIAL_PATH_SEGMENT)
|
||||
}
|
||||
|
||||
pub(super) fn percent_decode_http_url_path(input: &str) -> CompactString {
|
||||
if input.contains('%') {
|
||||
percent_decode_str(input).decode_utf8_lossy().into()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue