mirror of
https://github.com/Hopiu/lychee.git
synced 2026-05-24 05:13:44 +00:00
Clean up params and fragment handling
This commit is contained in:
parent
0c5dcf3aa3
commit
67268ed598
1 changed files with 5 additions and 6 deletions
|
|
@ -3,13 +3,12 @@ use linkify::LinkFinder;
|
|||
/// Remove all GET parameters from a URL.
|
||||
/// The link is not a URL but a String as it may not have a base domain.
|
||||
pub(crate) fn remove_get_params_and_fragment(url: &str) -> &str {
|
||||
let path = match url.split_once('#') {
|
||||
Some((path_without_fragment, _fragment)) => path_without_fragment,
|
||||
None => url,
|
||||
};
|
||||
let path = match path.split_once('?') {
|
||||
let path = match url.split_once('?') {
|
||||
Some((path_without_params, _params)) => path_without_params,
|
||||
None => path,
|
||||
None => match url.split_once('#') {
|
||||
Some((path_without_fragment, _fragment)) => path_without_fragment,
|
||||
None => url,
|
||||
},
|
||||
};
|
||||
path
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue