MCPcopy Create free account
hub / github.com/Cosmian/kms / extract_query_params

Function extract_query_params

crate/server_database/src/stores/sql/pgsql.rs:1529–1540  ·  view source on GitHub ↗

Extract query parameters from a `PostgreSQL` connection URL by splitting on `?`/`&`. This avoids `Url::parse()` which cannot handle multi-host connection strings.

(url: &str)

Source from the content-addressed store, hash-verified

1527/// Extract query parameters from a `PostgreSQL` connection URL by splitting on `?`/`&`.
1528/// This avoids `Url::parse()` which cannot handle multi-host connection strings.
1529fn extract_query_params(url: &str) -> HashMap<String, String> {
1530 let mut params = HashMap::new();
1531 if let Some(query_start) = url.find('?') {
1532 let query = &url[query_start + 1..];
1533 for pair in query.split('&') {
1534 if let Some((key, value)) = pair.split_once('=') {
1535 params.insert(key.to_owned(), value.to_owned());
1536 }
1537 }
1538 }
1539 params
1540}
1541
1542/// Rebuild the connection URL, removing only SSL-related query parameters.
1543/// Other parameters like `target_session_attrs` are preserved for `tokio-postgres`.

Calls 3

splitMethod · 0.80
findMethod · 0.45
insertMethod · 0.45