LCOV - code coverage report
Current view: top level - bliki-percent-encoding/src - lib.rs (source / functions) Coverage Total Hit
Test: bliki.lcov Lines: 0.0 % 28 0
Test Date: 2025-11-27 15:46:07 Functions: 0.0 % 2 0

            Line data    Source code
       1              : /// Percent-encode the string to escape ?, =, -, /, % and white space
       2              : /// characters so that they can safely be included in URLs.
       3              : ///
       4              : /// Ref: <https://developer.mozilla.org/en-US/docs/Glossary/Percent-encoding>
       5            0 : pub fn slugify(s: &str) -> String {
       6            0 :     let mut buf = String::new();
       7            0 :     for ch in s.chars() {
       8            0 :         match ch {
       9            0 :             ':' => buf.push_str("%3A"),
      10            0 :             '/' => buf.push_str("%2F"),
      11            0 :             '?' => buf.push_str("%3F"),
      12            0 :             '#' => buf.push_str("%23"),
      13            0 :             '[' => buf.push_str("%5B"),
      14            0 :             ']' => buf.push_str("%5D"),
      15            0 :             '@' => buf.push_str("%40"),
      16            0 :             '!' => buf.push_str("%21"),
      17            0 :             '$' => buf.push_str("%24"),
      18            0 :             '&' => buf.push_str("%26"),
      19            0 :             '\'' => buf.push_str("%27"),
      20            0 :             '(' => buf.push_str("%28"),
      21            0 :             ')' => buf.push_str("%29"),
      22            0 :             '*' => buf.push_str("%2A"),
      23            0 :             '+' => buf.push_str("%2B"),
      24            0 :             ',' => buf.push_str("%2C"),
      25            0 :             ';' => buf.push_str("%3B"),
      26            0 :             '=' => buf.push_str("%3D"),
      27            0 :             '%' => buf.push_str("%25"),
      28              :             _ => {
      29            0 :                 if ch.is_whitespace() {
      30            0 :                     buf.push_str("%20")
      31              :                 } else {
      32            0 :                     buf.push(ch)
      33              :                 }
      34              :             }
      35              :         }
      36              :     }
      37            0 :     buf
      38            0 : }
        

Generated by: LCOV version 2.0-1