Changeset View
Changeset View
Standalone View
Standalone View
src/registry.rs
Show First 20 Lines • Show All 134 Lines • ▼ Show 20 Lines | impl Repository { | ||||
pub fn exists(&self) -> bool { | pub fn exists(&self) -> bool { | ||||
let path = Path::new(&self.directory); | let path = Path::new(&self.directory); | ||||
path.exists() && path.is_dir() | path.exists() && path.is_dir() | ||||
} | } | ||||
pub fn is_valid_name(name: &str) -> bool { | pub fn is_valid_name(name: &str) -> bool { | ||||
lazy_static! { | lazy_static! { | ||||
static ref RE: Regex = Regex::new("^/?[a-zA-Z0-9_-]+$").unwrap(); | static ref RE: Regex = Regex::new("^[a-zA-Z0-9_-]+$").unwrap(); | ||||
} | } | ||||
RE.is_match(name) && name.len() <= 30 | RE.is_match(name) && name.len() <= 30 | ||||
} | } | ||||
pub fn is_valid_hash(hash: &str) -> bool { | pub fn is_valid_hash(hash: &str) -> bool { | ||||
lazy_static! { | lazy_static! { | ||||
static ref RE: Regex = Regex::new("^[a-f0-9]+$").unwrap(); | static ref RE: Regex = Regex::new("^[a-f0-9]+$").unwrap(); | ||||
▲ Show 20 Lines • Show All 120 Lines • Show Last 20 Lines |
Nasqueron DevCentral · If it had been much bigger the moon would have had a core of ice. · Powered by Phabricator