Skip to content

Commit 3ea7087

Browse files
committed
wrong escaping
1 parent 809cb01 commit 3ea7087

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

Diff for: src/JsonPointer.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class JsonPointer
1313
public static function escapeSegment($key, $isURIFragmentId = false)
1414
{
1515
if ($isURIFragmentId) {
16-
return str_replace(array('%2F', '%7E'), array('~0', '~1'), urlencode($key));
16+
return str_replace(array('%7E', '%2F'), array('~0', '~1'), urlencode($key));
1717
} else {
1818
return str_replace(array('~', '/'), array('~0', '~1'), $key);
1919
}

Diff for: tests/src/JsonPointerTest.php

+7
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,11 @@ public function testNumericKey()
4545
$json = json_decode('{"l1":{"200":1}}');
4646
$this->assertSame(1, JsonPointer::get($json, JsonPointer::splitPath('/l1/200')));
4747
}
48+
49+
50+
public function testEscapeSegment()
51+
{
52+
$segment = '/project/{username}/{project}';
53+
$this->assertSame('~1project~1%7Busername%7D~1%7Bproject%7D', JsonPointer::escapeSegment($segment, true));
54+
}
4855
}

0 commit comments

Comments
 (0)