add urn:said pre-processing support - #14
Conversation
kentbull
left a comment
There was a problem hiding this comment.
I'll approve your PR and then make the suggested changes.
| const [raw, sad] = deriveSAIDBytes(data, code, kind, label) | ||
| const said = qb64(raw, code) | ||
| const [raw, sad] = deriveSAIDBytes(data, code, kind, label, prefix) | ||
| const said = prefix + qb64(raw, code) |
There was a problem hiding this comment.
This is exposing that I took a shortcut for SAIDification by setting a property value rather than doing a string replace of the 44 pound sign # characters with the SAID. The code you wrote would work, yet let's be explicit and separate the SAID out from the finalized label that includes the prefix.
Change this so that the said var is still qb64(raw, code) and a new label var is used where:
- if
prefixis definedlabelis set toprefix + label- otherwise
labelissaid
This should be good enough for now.
| label: string = 'd', | ||
| code: string = SAIDDex.Blake3_256, | ||
| kind: Serials = Serials.JSON, | ||
| prefix: string = ``, |
There was a problem hiding this comment.
Use the single apostrophe quote here instead of backticks so we use the simplest tool possible.
| kind: Serials = Serials.JSON, | ||
| prefixed: boolean = false, | ||
| versioned: boolean = false, | ||
| prefix: string = ``, |
There was a problem hiding this comment.
Use the single apostrophe quote here instead of backticks so we use the simplest tool possible.
| // code = detectCode(data) | ||
| const [raw, derivedSad] = deriveSAIDBytes(sad, code, kind, label) | ||
| const [raw, derivedSad] = deriveSAIDBytes(sad, code, kind, label, prefix) | ||
| const computed = prefix + qb64(raw, code) |
There was a problem hiding this comment.
Similarly, here, where you have the computed const put the qb64(raw, code) into a said var and then use the same if (prefixed && prefix) check like above to construct the prefixed label.
Summary
Test plan