1
0
mirror of https://gitlab.com/comunic/comunicapiv3 synced 2024-11-23 05:49:22 +00:00
comunicapiv3/src/utils/string_utils.rs

19 lines
518 B
Rust

//! # String utilities
//!
//! This module contains utilities that can be used accross all the application
/// Escape an HTML string
///
/// Removes the HTML code included inside a string
///
/// ```
/// use comunic_server::utils::string_utils::remove_html_nodes;
///
/// let s1 = "<b>hello world</b>";
/// let res1 = remove_html_nodes(s1);
/// assert_eq!(res1, "&lt;b&gt;hello world&lt;/b&gt;");
/// ```
pub fn remove_html_nodes(input: &str) -> String {
input.replace("<", "&lt;")
.replace(">", "&gt;")
}