diff --git a/project.json b/project.json index f6ee0e6..5424afe 100644 --- a/project.json +++ b/project.json @@ -35,7 +35,7 @@ "company": "Nosial", "copyright": "Copyright (c) 2022-2023 Nosial", "description": "ConfigLib is a library for reading and writing configuration files via the NCC Runtime API", - "version": "1.1.0", + "version": "1.1.1", "uuid": "9347259e-8e4d-11ed-85a7-fd07cf28ef35" }, "build": { diff --git a/src/ConfigLib/Configuration.php b/src/ConfigLib/Configuration.php index 86ee637..62b604a 100644 --- a/src/ConfigLib/Configuration.php +++ b/src/ConfigLib/Configuration.php @@ -161,9 +161,7 @@ */ private static function validateKey(string $input): bool { - $pattern = '/^([a-zA-Z0-9]+\.?)+$/'; - - if (preg_match($pattern, $input)) + if (preg_match('/^([a-zA-Z0-9_]+\.?)+$/', $input)) { return true; } diff --git a/tests/ConfigLib/ConfigurationTest.php b/tests/ConfigLib/ConfigurationTest.php index a657551..2f8330b 100644 --- a/tests/ConfigLib/ConfigurationTest.php +++ b/tests/ConfigLib/ConfigurationTest.php @@ -52,8 +52,10 @@ class ConfigurationTest extends TestCase public function testGetMethodWithValidKey(): void { $config = new Configuration('test'); - $config->set('key1.key2', 'value'); + $this->assertTrue($config->set('key1.key2', 'value', true)); $this->assertEquals('value', $config->get('key1.key2')); + $this->assertTrue($config->set('foo.fizz_buzz', 'value', true)); + $this->assertEquals('value', $config->get('foo.fizz_buzz')); } /**