fix(rc2nix): correct regex for boolean values (#371)

Fix a regular expression in the `nix_val` function to correctly match and convert boolean values. The adjustment ensures that only exact matches for 'true' or 'false' are handled, preventing partial matches.
This commit is contained in:
Usama Ahsan 2024-09-24 20:58:55 +05:00 committed by GitHub
parent d3b59aea14
commit e3d60d6c8a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -276,7 +276,7 @@ class Rc2Nix:
def nix_val(s: Optional[str]) -> str: def nix_val(s: Optional[str]) -> str:
if s is None: if s is None:
return "null" return "null"
if re.match(r"^true|false$", s, re.IGNORECASE): if re.match(r"^(true|false)$", s, re.IGNORECASE):
return s.lower() return s.lower()
if re.match(r"^[0-9]+(\.[0-9]+)?$", s): if re.match(r"^[0-9]+(\.[0-9]+)?$", s):
return s return s