Skip to content

Commit

Permalink
bluesky: allow colons in record keys
Browse files Browse the repository at this point in the history
  • Loading branch information
snarfed committed Feb 26, 2024
1 parent 90cd8ad commit 7ff5c84
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ Changelog
* Prefer DID to handle in API calls that accept either.
* `at_uri_to_web_url`: support lists.
* Add `from_as1_to_strong_ref`.
* Allow `:`s in record keys ([atproto#2224](https://github.com/bluesky-social/atproto/discussions/2224)).
* `to_as1`:
* Convert blobs, [both new and old style](https://atproto.com/specs/data-model#blob-type), to PDS `getBlob` URLs.
* Add new `uri` kwarg.
Expand Down
10 changes: 6 additions & 4 deletions granary/bluesky.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import requests

from lexrpc import Client
from lexrpc.base import NSID_RE
from oauth_dropins.webutil import util
from oauth_dropins.webutil.util import trim_nulls

Expand All @@ -30,17 +31,18 @@
HANDLE_PATTERN = re.compile(r'^' + HANDLE_REGEX)
DID_WEB_PATTERN = re.compile(r'^did:web:' + HANDLE_REGEX)

# at:// URI regexp. Right now
# at:// URI regexp
# https://atproto.com/specs/at-uri-scheme#full-at-uri-syntax
# https://atproto.com/specs/record-key#record-key-syntax
# https://atproto.com/specs/nsid
# also see arroba.util.parse_at_uri
_CHARS = 'a-zA-Z0-9-.'
_CHARS = 'a-zA-Z0-9-.:'
# TODO: add query and fragment? they're currently unused in the protocol
# https://atproto.com/specs/at-uri-scheme#structure
AT_URI_PATTERN = re.compile(rf"""
^at://
(?P<repo>[{_CHARS}:]+)
(?:/(?P<collection>[{_CHARS}_~]+)
(?P<repo>[{_CHARS}]+)
(?:/(?P<collection>[a-zA-Z0-9-.]+)
(?:/(?P<rkey>[{_CHARS}]+))?)?
$""", re.VERBOSE)

Expand Down

0 comments on commit 7ff5c84

Please sign in to comment.