git-gemini-forge 0.5.2

A simple Gemini server that serves a read-only view of public repositories from a Git forge.
1
2
3
4
5
6
7
8
9
10
11
12
use regex::Regex;

/// Sanitizes the given string of repeating whitespace and newlines, truncating
/// these into a single space character. This string may NOT be suitable for
/// use as a URI component, but may be presented to the user on a single
/// line of Gemtext.
pub fn truncate_spaces(string: &str) -> String {
	let whitespace: Regex = Regex::new(r"\s+").unwrap();

	// Replace consecutive whitespace with a single space
	whitespace.replace_all(&string.trim(), " ").to_string()
}