Skip to content

Commit

Permalink
refactor(marshal): Change new-encoding prefix symbol from "#" to "~"
Browse files Browse the repository at this point in the history
This provides better differention w.r.t. smallcaps, cf.
#1594 (comment)
  • Loading branch information
gibson042 committed Sep 7, 2023
1 parent 213eb82 commit 79ef761
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions packages/marshal/src/encodePassable.js
Original file line number Diff line number Diff line change
Expand Up @@ -530,8 +530,8 @@ export const makeEncodePassable = (encodeOptions = {}) => {
}
};
const encodePassable = xxx
? // A leading "#" indicates the v2 encoding (with escaping in strings rather than arrays).
passable => `#${innerEncode(passable)}`
? // A leading "~" indicates the v2 encoding (with escaping in strings rather than arrays).
passable => `~${innerEncode(passable)}`
: innerEncode;
return harden(encodePassable);
};
Expand Down Expand Up @@ -618,8 +618,8 @@ export const makeDecodePassable = (decodeOptions = {}) => {
return innerDecode;
};
const decodePassable = encoded => {
// A leading "#" indicates the v2 encoding (with escaping in strings rather than arrays).
if (encoded.startsWith('#')) {
// A leading "~" indicates the v2 encoding (with escaping in strings rather than arrays).
if (encoded.startsWith('~')) {
const innerDecode = makeInnerDecode(
decodeStringWithEscapes,
decodeArrayWithoutEscapes,
Expand Down
4 changes: 2 additions & 2 deletions packages/marshal/test/test-encodePassable.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,10 @@ const goldenPairs = harden([
test('golden round trips', t => {
for (const [k, e] of goldenPairs) {
t.is(encodePassable(k), e, 'does k encode as expected');
t.is(encodePassable2(k), `#${e}`, 'does k small-encode as expected');
t.is(encodePassable2(k), `~${e}`, 'does k small-encode as expected');
t.is(decodePassable(e), k, 'does the key round trip through the encoding');
t.is(
decodePassable(`#${e}`),
decodePassable(`~${e}`),
k,
'does the small-encoded key round trip through the encoding',
);
Expand Down

0 comments on commit 79ef761

Please sign in to comment.