Fixed regex pattern for configuration properties being considered invalid when they contain an underscore.

This commit is contained in:
netkas 2024-10-29 00:23:02 -04:00
parent 6b446ce54a
commit 8d6a2c33bd
4 changed files with 23 additions and 9 deletions

14
.idea/php.xml generated
View file

@ -11,14 +11,16 @@
</component> </component>
<component name="PhpIncludePathManager"> <component name="PhpIncludePathManager">
<include_path> <include_path>
<path value="/var/ncc/packages/com.symfony.yaml=v7.1.4" /> <path value="/var/ncc/packages/net.nosial.optslib=1.1.2" />
<path value="/var/ncc/packages/com.symfony.polyfill_mbstring=v1.31.0" /> <path value="/var/ncc/packages/net.nosial.loglib=1.1.1" />
<path value="/var/ncc/packages/com.symfony.filesystem=v7.1.2" /> <path value="/var/ncc/packages/com.symfony.uid=v7.1.5" />
<path value="/var/ncc/packages/com.symfony.yaml=v7.1.5" />
<path value="/var/ncc/packages/com.symfony.filesystem=v7.1.5" />
<path value="/var/ncc/packages/com.symfony.polyfill_ctype=v1.31.0" /> <path value="/var/ncc/packages/com.symfony.polyfill_ctype=v1.31.0" />
<path value="/var/ncc/packages/com.symfony.process=v7.1.3" /> <path value="/var/ncc/packages/com.symfony.polyfill_mbstring=v1.31.0" />
<path value="/var/ncc/packages/net.nosial.optslib=1.1.0" /> <path value="/var/ncc/packages/com.symfony.polyfill_uuid=v1.31.0" />
<path value="/var/ncc/packages/com.symfony.process=v7.1.5" />
<path value="/usr/share/ncc" /> <path value="/usr/share/ncc" />
<path value="/var/ncc/packages/net.nosial.loglib=1.1.0" />
<path value="/usr/share/php" /> <path value="/usr/share/php" />
</include_path> </include_path>
</component> </component>

View file

@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [1.1.4] - Ongoing
This update introduces a minor bug fix
### Fixed
- Fixed regex pattern for configuration properties being considered invalid when they contain an underscore.
## [1.1.3] - 2024-10-13 ## [1.1.3] - 2024-10-13
This update introduces a new build system This update introduces a new build system

View file

@ -167,11 +167,10 @@
*/ */
private static function validateKey(string $input): bool private static function validateKey(string $input): bool
{ {
if (preg_match('/^([a-zA-Z0-9_]+\.?)+$/', $input)) if (preg_match('/^[a-zA-Z0-9_]+(\.[a-zA-Z0-9_]+)*$/', $input))
{ {
return true; return true;
} }
return false; return false;
} }

View file

@ -9,7 +9,11 @@ class ConfigurationTest extends TestCase
public static function setUpBeforeClass(): void public static function setUpBeforeClass(): void
{ {
$config = new Configuration('test'); $config = new Configuration('test');
unlink($config->getPath());
if(file_exists($config->getPath()))
{
unlink($config->getPath());
}
} }
public function testConstruct(): void public function testConstruct(): void
@ -24,6 +28,7 @@ class ConfigurationTest extends TestCase
$this->assertTrue($config->set('key1.key2', 'value', true)); $this->assertTrue($config->set('key1.key2', 'value', true));
$this->assertEquals('value', $config->get('key1.key2')); $this->assertEquals('value', $config->get('key1.key2'));
} }
public function testSetNotExists(): void public function testSetNotExists(): void