From 0c815b964c030aa0f277c40bf9786f130dc320f4 Mon Sep 17 00:00:00 2001 From: bnewbold Date: Fri, 23 Feb 2024 14:15:17 -0800 Subject: [PATCH] syntax: allow colon in record-key (#2223) * syntax: allow colon in record-key * changeset for rkey colon change --- .changeset/cuddly-adults-beg.md | 5 +++++ interop-test-files/syntax/aturi_syntax_valid.txt | 8 ++++++++ .../syntax/recordkey_syntax_invalid.txt | 5 +++-- .../syntax/recordkey_syntax_valid.txt | 13 +++++++++++++ packages/syntax/src/recordkey.ts | 2 +- 5 files changed, 30 insertions(+), 3 deletions(-) create mode 100644 .changeset/cuddly-adults-beg.md diff --git a/.changeset/cuddly-adults-beg.md b/.changeset/cuddly-adults-beg.md new file mode 100644 index 00000000000..b47c8101273 --- /dev/null +++ b/.changeset/cuddly-adults-beg.md @@ -0,0 +1,5 @@ +--- +'@atproto/syntax': minor +--- + +allow colon character in record-key syntax diff --git a/interop-test-files/syntax/aturi_syntax_valid.txt b/interop-test-files/syntax/aturi_syntax_valid.txt index 2552a964ce0..fd4523d0de9 100644 --- a/interop-test-files/syntax/aturi_syntax_valid.txt +++ b/interop-test-files/syntax/aturi_syntax_valid.txt @@ -24,3 +24,11 @@ at://did:plc:asdf123/com.atproto.feed.post/a at://did:plc:asdf123/com.atproto.feed.post/asdf-123 at://did:abc:123 at://did:abc:123/io.nsid.someFunc/record-key + +at://did:abc:123/io.nsid.someFunc/self. +at://did:abc:123/io.nsid.someFunc/lang: +at://did:abc:123/io.nsid.someFunc/: +at://did:abc:123/io.nsid.someFunc/- +at://did:abc:123/io.nsid.someFunc/_ +at://did:abc:123/io.nsid.someFunc/~ +at://did:abc:123/io.nsid.someFunc/... diff --git a/interop-test-files/syntax/recordkey_syntax_invalid.txt b/interop-test-files/syntax/recordkey_syntax_invalid.txt index 1da3d1e7dbc..52106d873a0 100644 --- a/interop-test-files/syntax/recordkey_syntax_invalid.txt +++ b/interop-test-files/syntax/recordkey_syntax_invalid.txt @@ -1,5 +1,4 @@ # specs -literal:self alpha/beta . .. @@ -10,5 +9,7 @@ any+space number[3] number(3) "quote" -pre:fix dHJ1ZQ== + +# too long: 'o'.repeat(513) +ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo diff --git a/interop-test-files/syntax/recordkey_syntax_valid.txt b/interop-test-files/syntax/recordkey_syntax_valid.txt index 8d77d04d2b7..92e8b7e31c9 100644 --- a/interop-test-files/syntax/recordkey_syntax_valid.txt +++ b/interop-test-files/syntax/recordkey_syntax_valid.txt @@ -3,6 +3,19 @@ self example.com ~1.2-3_ dHJ1ZQ +_ +literal:self +pre:fix + +# more corner-cases +: +- +_ +~ +... +self. +lang: +:lang # very long: 'o'.repeat(512) oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo diff --git a/packages/syntax/src/recordkey.ts b/packages/syntax/src/recordkey.ts index 6d424a1b8b4..a12668ff1e5 100644 --- a/packages/syntax/src/recordkey.ts +++ b/packages/syntax/src/recordkey.ts @@ -3,7 +3,7 @@ export const ensureValidRecordKey = (rkey: string): void => { throw new InvalidRecordKeyError('record key must be 1 to 512 characters') } // simple regex to enforce most constraints via just regex and length. - if (!/^[a-zA-Z0-9_~.-]{1,512}$/.test(rkey)) { + if (!/^[a-zA-Z0-9_~.:-]{1,512}$/.test(rkey)) { throw new InvalidRecordKeyError('record key syntax not valid (regex)') } if (rkey == '.' || rkey == '..')