Rm unused percent_encode_http_url_path

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
Jiahao XU 2024-05-28 00:55:24 +10:00
parent 1350ac342f
commit ffe47d30c6
No known key found for this signature in database
GPG key ID: 76D1E687CA3C4928

View file

@ -2,33 +2,13 @@ use std::{future::Future, sync::OnceLock, time::Duration};
use binstalk_downloader::remote::{self, header::HeaderMap, StatusCode, Url}; use binstalk_downloader::remote::{self, header::HeaderMap, StatusCode, Url};
use compact_str::CompactString; use compact_str::CompactString;
use percent_encoding::{ use percent_encoding::percent_decode_str;
percent_decode_str, utf8_percent_encode, AsciiSet, PercentEncode, CONTROLS,
};
use serde::{de::DeserializeOwned, Deserialize, Serialize}; use serde::{de::DeserializeOwned, Deserialize, Serialize};
use serde_json::to_string as to_json_string; use serde_json::to_string as to_json_string;
use tracing::debug; use tracing::debug;
use super::{GhApiError, GhGraphQLErrors}; 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 { pub(super) fn percent_decode_http_url_path(input: &str) -> CompactString {
if input.contains('%') { if input.contains('%') {
percent_decode_str(input).decode_utf8_lossy().into() percent_decode_str(input).decode_utf8_lossy().into()