diff --git a/src-tauri/yaak-templates/src/parser.rs b/src-tauri/yaak-templates/src/parser.rs index ac75e801..81df8826 100644 --- a/src-tauri/yaak-templates/src/parser.rs +++ b/src-tauri/yaak-templates/src/parser.rs @@ -323,7 +323,7 @@ impl Parser { let is_valid = if start_pos == self.pos { ch.is_alphanumeric() || ch == '_' // The first char is more restrictive } else { - ch.is_alphanumeric() || ch == '_' || ch == '-' + ch.is_alphanumeric() || ch == '_' || ch == '-' || ch == '.' }; if is_valid { text.push(ch); @@ -545,6 +545,22 @@ mod tests { Ok(()) } + #[test] + fn var_dots() -> Result<()> { + let mut p = Parser::new("${[ a.b ]}"); + assert_eq!( + p.parse()?.tokens, + vec![ + Token::Tag { + val: Val::Var { name: "a.b".into() } + }, + Token::Eof + ] + ); + + Ok(()) + } + #[test] fn var_prefixes() -> Result<()> { let mut p = Parser::new("${[ -a ]}${[ $a ]}"); diff --git a/src-web/components/EnvironmentEditor.tsx b/src-web/components/EnvironmentEditor.tsx index ff3bbfde..df60531e 100644 --- a/src-web/components/EnvironmentEditor.tsx +++ b/src-web/components/EnvironmentEditor.tsx @@ -74,7 +74,7 @@ export function EnvironmentEditor({ environment, hideName, className, setRef }: const validateName = useCallback((name: string) => { // Empty just means the variable doesn't have a name yet and is unusable if (name === '') return true; - return name.match(/^[a-z_][a-z0-9_-]*$/i) != null; + return name.match(/^[a-z_][a-z0-9_.-]*$/i) != null; }, []); const valueType = !isEncryptionEnabled && valueVisibility.value ? 'text' : 'password';