Skip to content

Conversation

@uniphil
Copy link
Contributor

@uniphil uniphil commented May 24, 2025

A few months ago, the spec was updated to the relax NSID syntax for the name (last) segment of NSIDs: non-leading digits are now permitted: bluesky-social/atproto-website#402

This change adds the new examples from the updated spec to the tests, and passes those test by adding 0-9 to the middle and end [] groups of the NSID regex.

This is a minimal change to pass the tests, but the name segment matcher could be further simplified:

(\.[a-zA-Z]([a-zA-Z]{0,61}[a-zA-Z])?)  # before
(\.[a-zA-Z]([a-zA-Z0-9]{0,61}[a-zA-Z0-9])?)  # this PR
(\.[a-zA-Z][a-zA-Z0-9]{0,62})  # PR-equivalent except internal capture group

but that refactor is kind of to taste. happy to update the PR if you like it. as-is this PR has a bit more pattern consistency with the earlier segment matchers.

uniphil added 2 commits May 24, 2025 19:38
A few months ago, the spec was updated to the relax NSID syntax for the 'name' (last) NSID segment: non-leading digits are now permitted: bluesky-social/atproto-website#402

This change adds the new examples from the updated spec, which fail the current regex.
Fixes the failing tests with the [updated](bluesky-social/atproto-website#402) example NSIDs from the spec.

This was a minimal change (just adding the `0-9`s), but i think the name-segment matcher could be further simplified:

```
(\.[a-zA-Z]([a-zA-Z0-9]{0,61}[a-zA-Z0-9])?)  # current
(\.[a-zA-Z][a-zA-Z0-9]{0,62})  # simpler, equivalent except for the internal capture group
```

but i will leave deciding that to maintainer taste.
@sugyan sugyan self-requested a review May 25, 2025 13:07
Copy link
Member

@sugyan sugyan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the pull request! I was not aware of this change, so this is very helpful.

I think the (\.[a-zA-Z][a-zA-Z0-9]{0,62}) change is better.
And if you run the cargo fmt, the Actions failures will be resolved.

@uniphil
Copy link
Contributor Author

uniphil commented May 25, 2025

sounds good! updated to the shorter regex and ran fmt -- i only added changes from string.rs, fmt seemed to touch a lot of files.

@sugyan sugyan merged commit 6310be7 into atrium-rs:main May 25, 2025
14 checks passed
@github-actions github-actions bot mentioned this pull request May 25, 2025
@sugyan
Copy link
Member

sugyan commented May 26, 2025

Thank you for your contribution!
Your fix is included in atrium-api 0.25.4.

https://github.com/atrium-rs/atrium/blob/main/atrium-api/CHANGELOG.md#0254---2025-05-25

@uniphil uniphil deleted the fix/nsid-allow-nonleading-name-digits branch May 29, 2025 22:15
@uniphil
Copy link
Contributor Author

uniphil commented May 29, 2025

amazing, thank you @sugyan !!!!

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 this pull request may close these issues.

2 participants