Skip to content

Commit 99c2994

Browse files
authored
Merge pull request #16 from graze/null-line-ending-support
Add support for null line endings
2 parents c31c952 + 1f19b2b commit 99c2994

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

src/PromptMatcher.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class PromptMatcher implements PromptMatcherInterface
3636
public function isMatch($prompt, $subject, $lineEnding = null)
3737
{
3838
// cheap line ending check before expensive regex
39-
if (substr($subject, -1 * strlen($lineEnding)) != $lineEnding) {
39+
if (!is_null($lineEnding) && substr($subject, -1 * strlen($lineEnding)) != $lineEnding) {
4040
return false;
4141
}
4242

tests/unit/PromptMatcherTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ public function dataProviderIsMatch()
3939
{
4040
return [
4141
['OK', 'this is a response', "\n", false],
42+
['OK', 'this is a response', null, false], // null line ending
4243
['OK', "this is a response\nOK\n", "\n", true, ['OK'], 'this is a response'],
4344
['(ERROR) ([0-9]{1,3})', "party\r\nERROR 123\r\n", "\r\n", true, ['ERROR 123', 'ERROR', '123'], 'party']
4445
];

0 commit comments

Comments
 (0)