Skip to content

Commit

Permalink
Merge pull request #3 from mkatychev/fix/number_values_in_cut_var
Browse files Browse the repository at this point in the history
allow numbers it cut vars
  • Loading branch information
mkatychev authored Jul 16, 2021
2 parents 2cb78eb + d7e1ccd commit 5e92a3b
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#### `0.7.3`:
* changed valid cut variable regex from `[A-Za-z_]` to `[A-Za-z_0-9]` as alpha _numerics_ were the intended format

#### `0.7.2`:
* migrated `cargho` back to `argh` since new version was released

Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "darkroom"
version = "0.7.2"
version = "0.7.3"
description = "A contract testing tool built in Rust"
authors = ["Mikhail Katychev <[email protected]>"]
edition = "2018"
Expand Down
2 changes: 1 addition & 1 deletion filmreel/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "filmreel"
version = "0.6.1"
version = "0.6.2"
description = "filmReel parser for Rust"
authors = ["Mikhail Katychev <[email protected]>"]
edition = "2018"
Expand Down
14 changes: 7 additions & 7 deletions filmreel/src/cut.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub struct Register {
}

const VAR_NAME_ERR: &str = "Only alphanumeric characters, dashes, and underscores are permitted \
in Cut Variable names => [A-Za-z_]";
in Cut Variable names => [A-Za-z_0-9]";

/// The Register's map of [Cut Variables]
/// (https://github.com/mkatychev/filmReel/blob/master/cut.md#cut-variable)
Expand Down Expand Up @@ -123,10 +123,10 @@ impl Register {
lazy_static! {
static ref VAR_MATCH: Regex = Regex::new(
r"(?x)
(?P<esc_char>\\)? # escape character
(?P<leading_b>\$\{) # leading brace
(?P<cut_var>[A-za-z_0-9]+) # Cut Variable
(?P<trailing_b>})? # trailing brace
(?P<esc_char>\\)? # escape character
(?P<leading_b>\$\{) # leading brace
(?P<cut_var>[A-Za-z_0-9]+) # Cut Variable
(?P<trailing_b>})? # trailing brace
"
)
.unwrap();
Expand Down Expand Up @@ -276,7 +276,7 @@ impl Register {
pub fn write_operation(&mut self, key: &str, val: Value) -> Result<Option<Value>, FrError> {
lazy_static! {
// Permit only alphachars dashes and underscores for variable names
static ref KEY_CHECK: Regex = Regex::new(r"^[A-Za-z_]+$").unwrap();
static ref KEY_CHECK: Regex = Regex::new(r"^[A-Za-z_0-9]+$").unwrap();
}
if !KEY_CHECK.is_match(key) {
return Err(FrError::FrameParsef(VAR_NAME_ERR, key.to_string()));
Expand All @@ -288,7 +288,7 @@ impl Register {
pub fn flush_ignored(&mut self) {
lazy_static! {
// if key value consists of only lowercase letters and underscores
static ref KEY_IGNORE: Regex = Regex::new(r"^[a-z_]+$").unwrap();
static ref KEY_IGNORE: Regex = Regex::new(r"^[a-z_0-9]+$").unwrap();
}
let mut remove: Vec<String> = vec![];
for (k, _) in self.vars.iter() {
Expand Down

0 comments on commit 5e92a3b

Please sign in to comment.