Skip to content

Commit

Permalink
Fix regex for toBeValidDid/isValidDid to match with ABNF rules in lat…
Browse files Browse the repository at this point in the history
…est spec.
  • Loading branch information
etaleo authored May 21, 2021
1 parent 1ddb28c commit 262f6dc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ describe('.toBeValidDid', () => {
["did:example:123456789abcdefghi"],
["did:example:123456789-abcdefghi"],
["did:example:123456789_abcdefghi"],
["did:example:123456789%20abcdefghi"]
["did:example:123456789%20abcdefghi"],
["did:example:123abc:123456789abcdefghi"],
]).test('passes when the item is a valid DID: %s', given => {
expect(given).toBeValidDid();
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export default expected => {
const didRegex = /^did:(?<method_name>[a-z0-9]+):(?<method_specific_id>([a-zA-Z0-9.\-_]|%[0-9a-fA-F]{2}|:)+$)/;
const didRegex = /^did:(?<method_name>[a-z0-9]+):(?<method_specific_id>([a-zA-Z0-9.\-_]|%[0-9a-fA-F]{2}|:)+[^:]$)/;
return didRegex.test(expected);
};

0 comments on commit 262f6dc

Please sign in to comment.