Skip to main content

normalize_exclude_pattern

Function normalize_exclude_pattern 

Source
pub fn normalize_exclude_pattern(root: &Path, path: &Path) -> String
Expand description

Normalize an exclude path into a deterministic pattern.

Rules:

  • if path is absolute and under root, strip the root prefix
  • convert backslashes to /
  • strip one leading ./

ยงExamples

use std::path::Path;
use tokmd_exclude::normalize_exclude_pattern;

let root = Path::new("/project");
let relative = Path::new("./out/bundle.js");
assert_eq!(normalize_exclude_pattern(root, relative), "out/bundle.js");