MarshalX / atproto

The AT Protocol (🦋 Bluesky) SDK for Python 🐍
https://atproto.blue
MIT License
309 stars 33 forks source link

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

Closed max2pt0 closed 9 months ago

max2pt0 commented 9 months ago

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

MarshalX commented 9 months ago

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

MarshalX commented 9 months ago

fixed in v0.0.37