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

improve did parser for port and path #24

Merged
merged 2 commits into from
Oct 16, 2023

Conversation

2byrds
Copy link
Contributor

@2byrds 2byrds commented Oct 15, 2023

Improve regex for did:webs to include port group and added unit tests.

@2byrds 2byrds requested a review from peacekeeper October 15, 2023 19:53
@2byrds 2byrds marked this pull request as ready for review October 15, 2023 19:55
@@ -16,12 +16,12 @@
from keri.core import coring

DID_KERI_RE = re.compile('\\Adid:keri:(?P<aid>[^:]+)\\Z', re.IGNORECASE)
DID_WEBS_RE = re.compile('\\Adid:webs:(?P<domain>[^:]+):((?P<path>.+):)?(?P<aid>[^:]+)\\Z', re.IGNORECASE)
DID_WEBS_RE = re.compile('\\Adid:webs:(?P<domain>[^:]+)(:(?P<port>\d+))?(:(?P<path>.+))?(:(?P<aid>[^:]+)+)\\Z', re.IGNORECASE)
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm according to the spec:

A port MAY be included and the colon MUST be percent encoded to prevent a conflict with paths.

Maybe the regex should use %3A instead of : for parsing the port and avoiding a conflict with the path?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great catch @peacekeeper ! I have updated it per the spec (and fixed my assertions in the unit test) in commit 6f3ce57

@peacekeeper peacekeeper merged commit 6149184 into hyperledger-labs:main Oct 16, 2023
2 checks passed
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