Skip to main content

normalize_host

Function normalize_host 

Source
pub fn normalize_host(host: &str) -> String
Expand description

Normalize a host value by stripping any protocol prefix and trailing slashes.

This handles cases where users provide a full URL (e.g., https://gitlab.example.com/) instead of a bare hostname (e.g., gitlab.example.com).

ยงExamples

use jj_ryu::normalize_host;

assert_eq!(normalize_host("gitlab.com"), "gitlab.com");
assert_eq!(normalize_host("https://gitlab.com"), "gitlab.com");
assert_eq!(normalize_host("http://gitlab.com/"), "gitlab.com");
assert_eq!(normalize_host("https://gitlab.example.com/some/path"), "gitlab.example.com");