Skip to content

Commit

Permalink
fixes #33 (Util::getLiteralValue() fails for multiline values) (#38)
Browse files Browse the repository at this point in the history
  • Loading branch information
k00ni authored Mar 30, 2021
1 parent 9230173 commit 8bebaa0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Util.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public static function inDefaultGraph(array $triple): bool
*/
public static function getLiteralValue(string $literal)
{
preg_match('/^"(.*)"/', $literal, $match); //TODO: somehow the copied regex did not work. To be checked. Contained [^]
preg_match('/^"(.*)"/s', $literal, $match); //TODO: somehow the copied regex did not work. To be checked. Contained [^]
if (empty($match)) {
throw new \Exception($literal.' is not a literal');
}
Expand Down
2 changes: 2 additions & 0 deletions test/UtilTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ public function testGetLiteralValue(): void
// it gets the value of a literal with a cariage return
$this->assertEquals('Mickey\rMouse', Util::getLiteralValue('"Mickey\rMouse"'));

$this->assertEquals("foo\nbar", Util::getLiteralValue('"' . "foo\nbar" . '"'));

// it does not work with non-literals
//TODO: Util::getLiteralValue.bind(null, 'http://ex.org/').should.throw('http://ex.org/ is not a literal');

Expand Down

0 comments on commit 8bebaa0

Please sign in to comment.