Skip to content

Commit

Permalink
syntax: allow colon in record-key (bluesky-social#2223)
Browse files Browse the repository at this point in the history
* syntax: allow colon in record-key

* changeset for rkey colon change
  • Loading branch information
bnewbold authored Feb 23, 2024
1 parent 4353190 commit 0c815b9
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/cuddly-adults-beg.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@atproto/syntax': minor
---

allow colon character in record-key syntax
8 changes: 8 additions & 0 deletions interop-test-files/syntax/aturi_syntax_valid.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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/...
5 changes: 3 additions & 2 deletions interop-test-files/syntax/recordkey_syntax_invalid.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# specs
literal:self
alpha/beta
.
..
Expand All @@ -10,5 +9,7 @@ any+space
number[3]
number(3)
"quote"
pre:fix
dHJ1ZQ==

# too long: 'o'.repeat(513)
ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
13 changes: 13 additions & 0 deletions interop-test-files/syntax/recordkey_syntax_valid.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion packages/syntax/src/recordkey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 == '..')
Expand Down

0 comments on commit 0c815b9

Please sign in to comment.