pub struct Utils;Implementationsยง
Sourceยงimpl Utils
impl Utils
Sourcepub fn substring_after_scheme<'a>(parser: &Parser, input: &'a str) -> &'a str
pub fn substring_after_scheme<'a>(parser: &Parser, input: &'a str) -> &'a str
Get substring immediately after scheme.
ยงExample
use url_parse::utils::Utils;
use url_parse::core::Parser;
let input =
"https://user:pass@www.example.co.uk:443/blog/article/search?docid=720&hl=en#dayone";
let expected =
"user:pass@www.example.co.uk:443/blog/article/search?docid=720&hl=en#dayone".to_string();
let parser = Parser::new(None);
let result = Utils::substring_after_scheme(&parser, input);
assert_eq!(result, expected);Sourcepub fn substring_after_login<'a>(parser: &Parser, input: &'a str) -> &'a str
pub fn substring_after_login<'a>(parser: &Parser, input: &'a str) -> &'a str
Get substring immediately after login. Eliminates scheme to ensure no colon present in remainder.
ยงExample
use url_parse::utils::Utils;
use url_parse::core::Parser;
let input =
"https://user:pass@www.example.co.uk:443/blog/article/search?docid=720&hl=en#dayone";
let expected = "www.example.co.uk:443/blog/article/search?docid=720&hl=en#dayone".to_string();
let parser = Parser::new(None);
let result = Utils::substring_after_login(&parser, input);
assert_eq!(result, expected);Sourcepub fn substring_after_port<'a>(parser: &Parser, input: &'a str) -> &'a str
pub fn substring_after_port<'a>(parser: &Parser, input: &'a str) -> &'a str
Get substring immediately after port. Eliminates scheme to ensure no colon present in remainder.
ยงExample
use url_parse::utils::Utils;
use url_parse::core::Parser;
let input =
"https://user:pass@www.example.co.uk:443/blog/article/search?docid=720&hl=en#dayone";
let expected = "www.example.co.uk:443/blog/article/search?docid=720&hl=en#dayone".to_string();
let parser = Parser::new(None);
let result = Utils::substring_after_login(&parser, input);
assert_eq!(result, expected);Sourcepub fn substring_before_port<'a>(parser: &Parser, input: &'a str) -> &'a str
pub fn substring_before_port<'a>(parser: &Parser, input: &'a str) -> &'a str
Get substring immediately before port.
ยงExample
use url_parse::utils::Utils;
use url_parse::core::Parser;
let input = "https://www.example.co.uk:443/blog/article/search?docid=720&hl=en#dayone";
let expected = "https://www.example.co.uk".to_string();
let parser = Parser::new(None);
let result = Utils::substring_before_port(&parser, input);
assert_eq!(result, expected);Sourcepub fn substring_from_path_begin<'a>(
parser: &Parser,
input: &'a str,
) -> Option<&'a str>
pub fn substring_from_path_begin<'a>( parser: &Parser, input: &'a str, ) -> Option<&'a str>
Get substring starting at path field. Eliminates scheme to ensure no colon present in remainder.
ยงExample
use url_parse::utils::Utils;
use url_parse::core::Parser;
let input =
"https://user:pass@www.example.co.uk:443/blog/article/search?docid=720&hl=en#dayone";
let expected =
"/blog/article/search?docid=720&hl=en#dayone".to_string();
let parser = Parser::new(None);
let result = Utils::substring_from_path_begin(&parser, input).unwrap_or("");
assert_eq!(result, expected);Sourcepub fn canonicalize<'a>(
parser: &Parser,
input: &'a str,
subpath: &'a str,
) -> String
pub fn canonicalize<'a>( parser: &Parser, input: &'a str, subpath: &'a str, ) -> String
Partially matches a subpath in a path. Useful for i.e. GitHub absolute paths from URL hrefs.
ยงExample
use url_parse::utils::Utils;
use url_parse::core::Parser;
let input = "https://github.com/mihaigalos/aim/releases/tag/1.5.4";
let subpath = "mihaigalos/aim/releases/download/1.5.4/aim-1.5.4-x86_64-unknown-linux-gnu.tar.gz";
let expected = "https://github.com/mihaigalos/aim/releases/download/1.5.4/aim-1.5.4-x86_64-unknown-linux-gnu.tar.gz";
let result = Utils::canonicalize(&Parser::new(None), input, subpath);
assert_eq!(result, expected);Auto Trait Implementationsยง
impl Freeze for Utils
impl RefUnwindSafe for Utils
impl Send for Utils
impl Sync for Utils
impl Unpin for Utils
impl UnsafeUnpin for Utils
impl UnwindSafe for Utils
Blanket Implementationsยง
Sourceยงimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Sourceยงfn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more