Sha256: 58d8ba4a95a84497f0de004392276200a0f24251e5e3a50f294fbbfe4e0decde

Contents?: true

Size: 344 Bytes

Versions: 3

Compression:

Stored size: 344 Bytes

Contents

use path_parsing::extract_last_path_segment;

pub fn extname(pth: &str) -> String {
  let name = extract_last_path_segment(pth);

  if let Some(dot_i) = name.rfind('.') {
    if dot_i > 0 && dot_i < name.len() - 1 && name[..dot_i].chars().rev().next().unwrap() != '.' {
      return String::from(&name[dot_i..])
    }
  }

  String::from("")
}

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
faster_path-0.2.2 src/extname.rs
faster_path-0.2.1 src/extname.rs
faster_path-0.2.0 src/extname.rs