diff --git a/payjoin/src/uri/url_ext.rs b/payjoin/src/uri/url_ext.rs index b5047ee5..94a7c6e8 100644 --- a/payjoin/src/uri/url_ext.rs +++ b/payjoin/src/uri/url_ext.rs @@ -97,18 +97,19 @@ impl UrlExt for Url { } } +/// Get a parameter from the URL fragment +/// +/// This function is case insensitive fn get_param(url: &Url, prefix: &str, parse: F) -> Option where F: Fn(&str) -> Option, { - if let Some(fragment) = url.fragment() { - for param in fragment.split('+') { - if param.starts_with(prefix) { - return parse(param); - } - } - } - None + let prefix = prefix.to_uppercase(); + url.fragment()? + .to_uppercase() + .split('+') + .find(|param| param[..prefix.len()] == prefix) + .and_then(parse) } fn set_param(url: &mut Url, prefix: &str, param: &str) {