Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
max2pt0 opened this issue Jan 11, 2024 · 2 comments · Fixed by #229
Closed

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

max2pt0 opened this issue Jan 11, 2024 · 2 comments · Fixed by #229

Comments

@max2pt0
Copy link

max2pt0 commented Jan 11, 2024

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
Copy link
Owner

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

@MarshalX
Copy link
Owner

fixed in v0.0.37

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants