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

Lex: more string formats #688

Merged
merged 19 commits into from
Mar 20, 2023
Merged

Lex: more string formats #688

merged 19 commits into from
Mar 20, 2023

Conversation

dholms
Copy link
Collaborator

@dholms dholms commented Mar 17, 2023

This introduces 4 new string formats:

  • handle
  • nsid
  • uri (generally, as opposed to the specific case of at-uri)
  • at-identifier (this is just the union of did & handle)

I did not add the at-uri format to moderation method subjects. Wanted to coordinate with @devinivy on that to make sure it makes sense.

I also briefly tried out switching cid references in the cbor-only subscribeRepos method to cid-internal-ref but hit a hiccup because dag-cbor does not support concatenated cbor & cborx was not playing nicely with it.

Closes #580

@dholms dholms changed the base branch from main to lex/cids-and-bytes March 18, 2023 20:23
@dholms dholms marked this pull request as ready for review March 18, 2023 20:23
Base automatically changed from lex/cids-and-bytes to lex-refactor March 18, 2023 20:24
@dholms dholms mentioned this pull request Mar 18, 2023
@devinivy
Copy link
Collaborator

Might be a little side-quest, but I think we should be able to add support for CIDs to cbor-x with a custom extension. We have an open thread rvagg/cborg#75 on cborg (used by @ipld/dag-cbor) to support streaming cbor, but it's probably not the shortest path to getting this working yet.

@dholms
Copy link
Collaborator Author

dholms commented Mar 18, 2023

Yeah I thought about that 🤔

I'll take a look & see what i can cook up

@dholms
Copy link
Collaborator Author

dholms commented Mar 18, 2023

hot dog: #693

}

export function uri(path: string, value: string): ValidationResult {
const isUri = value.match(/\w+:(\/?\/?)[^\s]+/) !== null
Copy link
Collaborator

Choose a reason for hiding this comment

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

Since [^\s]+ covers \/?\/?, I am not sure the (\/?\/?) is affecting the result. But I also see why it's there / what it's getting at. Just to toss a close alternative out there:

Suggested change
const isUri = value.match(/\w+:(\/?\/?)[^\s]+/) !== null
const isUri = value.match(/\w+:(?:\/\/)?[^\s\/][^\s]*/) !== null

If we're not 100% sure how we want it, I think it's also totally cool to leave it as-is and come back to it later.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

nice im game 👌

return []
}
try {
ident.ensureValidDid(subject)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Very glad about this, I felt a little dirty dipping into lexicon internals.

Copy link
Collaborator

@devinivy devinivy left a comment

Choose a reason for hiding this comment

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

👏 lovely

@dholms dholms merged commit 6586d04 into lex-refactor Mar 20, 2023
@dholms dholms deleted the lex/more-formats branch March 20, 2023 02:49
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.

Lexicon updates: new types, string formats
2 participants