Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update variable regex to support hyphens (#503)
## Changes Modified interpolation logic to use: `\$\{([a-zA-Z]+([-_]*[a-zA-Z0-9]+)*(\.[a-zA-Z]+([-_]*[a-zA-Z0-9]+)*)*)\}` **Edit**: Suggested by @pietern `\$\{([a-zA-Z]+([-_]?[a-zA-Z0-9]+)*(\.[a-zA-Z]+([-_]?[a-zA-Z0-9]+)*)*)\}` to be more selective and not allow consequent hyphens or underscores to make the keys more readable. Explanation: 1. All interpolation starts with `${` and ends with `}` 2. All interpolated locations are split by by `.` 3. All sections are expected to start with a alphabet `[a-zA-Z]`; no numbers, hyphens or underscores. 4. All sections are expected to end with an alphanumeric `[a-zA-Z0-9]` no hyphens or underscores This change allows the current interpolation to be more permissive. **Note** it does break backwards compatibility because `[a-zA-Z] != [\w]`. `\w` includes alphanumeric and underscores. `\w = [a-zA-Z0-9_]` ## Tests There are two tests with examples of valid and invalid interpolation and a test to validate expansion.
- Loading branch information