Sha256: 657064dd6a410f13dfadedf151a9dc68d39c0b8f5ac9aa0d1fbe17566cd44cb6

Contents?: true

Size: 553 Bytes

Versions: 8

Compression:

Stored size: 553 Bytes

Contents

use dirname::dirname;
use basename::basename;
use std::path::MAIN_SEPARATOR as SEP;

pub fn prepend_prefix(prefix: &str, relpath: &str) -> String {
  let mut prefix: String = prefix.to_string();
  if relpath.is_empty() {
    dirname(&prefix).to_string()
  } else if prefix.contains(&SEP.to_string()[..]) {
    prefix = dirname(&prefix).to_string();
    if basename(&format!("{}{}", &prefix, "a"), "") != "a" {
      prefix = format!("{}{}", prefix, &SEP);
    }
    format!("{}{}", prefix, relpath)
  } else {
    format!("{}{}", prefix, relpath)
  }
}

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
faster_path-0.3.7 src/prepend_prefix.rs
faster_path-0.3.6 src/prepend_prefix.rs
faster_path-0.3.2 src/prepend_prefix.rs
faster_path-0.3.1 src/prepend_prefix.rs
faster_path-0.2.6 src/prepend_prefix.rs
faster_path-0.2.5 src/prepend_prefix.rs
faster_path-0.2.4 src/prepend_prefix.rs
faster_path-0.2.3 src/prepend_prefix.rs