From 67268ed59842662c5775d935481c3def974371a2 Mon Sep 17 00:00:00 2001 From: Matthias Date: Tue, 7 Sep 2021 13:02:39 +0200 Subject: [PATCH] Clean up params and fragment handling --- lychee-lib/src/helpers/url.rs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/lychee-lib/src/helpers/url.rs b/lychee-lib/src/helpers/url.rs index 12b822b..3a830f9 100644 --- a/lychee-lib/src/helpers/url.rs +++ b/lychee-lib/src/helpers/url.rs @@ -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 }