MarshalX/atproto

AtUri.from_str() returns invalid host for some AT uri's (Fix included)

max2pt0 opened this issue · 2 comments

Example: AtUri.from_str("at://100ideas.bsky.social").hostname
returns: at:
should return: 100ideas.bsky.social

Fix: This implementation is based on a REGEX string from bluesky-social and they've updated and changed this string. Making similar change here fixes the problem.

In packages/atproto_core/uri/uri.py change _ATP_URI_REGEX

from: _ATP_URI_REGEX = r'^(at:\/\/)?((?:did:[a-z0-9:%-]+)|(?:[a-z][a-z0-9.:-]*))(\/[^?#\s]*)?(\?[^#\s]+)?(#[^\s]+)?$'
to  : _ATP_URI_REGEX = r'^(at:\/\/)?((?:did:[a-z0-9:%-]+)|(?:[a-z0-9][a-z0-9.:-]*))(\/[^?#\s]*)?(\?[^#\s]+)?(#[^\s]+)?$'

based on ref: https://github.com/bluesky-social/atproto/blob/8c19ce991a766fd9cff5023160853ab1cb106f21/packages/uri/src/index.ts#LL5C38-L5C38

Thanks

Thank you! Fixed. Will be included in the next release

fixed in v0.0.37