Skip to content

Commit f1a5fef

Browse files
authored
Merge pull request #2894 from antograssiot/composite-identifiers-parsing
Allow to extract blank values from composite identifier
2 parents 44f45d1 + 92bfe84 commit f1a5fef

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/Identifier/CompositeIdentifierParser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public static function parse(string $identifier): array
3333
{
3434
$matches = [];
3535
$identifiers = [];
36-
$num = preg_match_all('/(\w+)=(?<=\w=)(.+?)(?=;\w+=)|(\w+)=([^;]+);?$/', $identifier, $matches, PREG_SET_ORDER);
36+
$num = preg_match_all('/(\w+)=(?<=\w=)(.*?)(?=;\w+=)|(\w+)=([^;]*);?$/', $identifier, $matches, PREG_SET_ORDER);
3737

3838
foreach ($matches as $i => $match) {
3939
if ($i === $num - 1) {

tests/Identifier/CompositeIdentifierParserTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ public function variousIdentifiers(): array
3737
'a=test;b=bar;foo;c=123' => ['a' => 'test', 'b' => 'bar;foo', 'c' => '123'],
3838
'a=test;b=bar ;foo;c=123;459;barz=123asgfjasdg4;' => ['a' => 'test', 'b' => 'bar ;foo', 'c' => '123;459', 'barz' => '123asgfjasdg4'],
3939
'foo=test=bar;;bar=bazzz;' => ['foo' => 'test=bar;', 'bar' => 'bazzz'],
40+
'foo=test=bar;bar=;test=foo' => ['foo' => 'test=bar', 'bar' => '', 'test' => 'foo'],
41+
'foo=test=bar;bar=' => ['foo' => 'test=bar', 'bar' => ''],
4042
]]];
4143
}
4244
}

0 commit comments

Comments
 (0)