Skip to content

Commit

Permalink
Fix env change selection
Browse files Browse the repository at this point in the history
  • Loading branch information
augustuswm committed Feb 4, 2019
1 parent 6b1ee78 commit 9d23439
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
authors = ["Augustus Mayo <gusmayo@gmail.com>"]
edition = "2018"
name = "envfmt"
version = "0.2.0"
version = "0.4.0"
license = "Apache-2.0"

[badges]
Expand Down
11 changes: 4 additions & 7 deletions src/params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ impl ParamBag {
for parameter in parameters {
if let (Some(name), Some(value)) = (parameter.name, parameter.value) {
self.params.push(Param {
key: to_env_name(self.prefix.as_str(), name.as_str()),
key: to_env_name(name.as_str()).to_string(),
value,
});
}
Expand All @@ -95,8 +95,8 @@ pub fn make_path_req(path: &str, next_token: Option<String>) -> GetParametersByP
}
}

pub fn to_env_name(prefix: &str, name: &str) -> String {
name.trim_start_matches(prefix).to_uppercase()
pub fn to_env_name(name: &str) -> String {
name[name.rfind('/').unwrap_or(0) + 1..].to_uppercase()
}

pub fn get_all_params_for_path<T>(client: &T, path: &str) -> ParamResult
Expand Down Expand Up @@ -253,10 +253,7 @@ mod tests {

#[test]
fn test_converts_to_env_var_name() {
assert_eq!(
"PARAM_KEY",
to_env_name("/path/to/the/", "/path/to/the/param_key")
);
assert_eq!("PARAM_KEY", to_env_name("/path/to/the/param_key"));
}

#[test]
Expand Down

0 comments on commit 9d23439

Please sign in to comment.