Function mask_url

Source
pub fn mask_url(url: &str) -> String
Expand description

Masks a URL by showing only the scheme and host, hiding the path and query parameters.

This is used to safely display RPC URLs in API responses and logs without exposing sensitive API keys that are often embedded in the URL path or query string.

§Examples

  • https://eth-mainnet.g.alchemy.com/v2/abc123https://eth-mainnet.g.alchemy.com/***
  • https://mainnet.infura.io/v3/PROJECT_IDhttps://mainnet.infura.io/***
  • http://localhost:8545http://localhost:8545 (no path to mask)
  • invalid-url*** (fallback for unparsable URLs)