feat: template tag to encode hex to base64#6211
Merged
jackkav merged 2 commits intoKong:developfrom Jan 29, 2024
Merged
Conversation
nbgraham
commented
Jul 28, 2023
Comment on lines
+63
to
+64
| } else if (kind === hex) { | ||
| return Buffer.from(text, 'hex').toString('base64'); |
nbgraham
commented
Jul 28, 2023
| run(_context, action, kind, text) { | ||
| text = text || ''; | ||
| invariant(action === encode || action === decode, 'invalid action'); | ||
| invariant(kind === normal || kind === url || kind === hex, 'invalid kind'); |
nbgraham
commented
Jul 28, 2023
Comment on lines
+73
to
+74
| if (kind === hex) { | ||
| return Buffer.from(text, 'base64').toString('hex'); |
nbgraham
commented
Jul 28, 2023
| return Buffer.from(text, 'base64').toString('utf8'); | ||
| } | ||
| } | ||
| throw new Error('unknown options'); |
nbgraham
commented
Jul 28, 2023
Comment on lines
+18
to
+23
| const encode = 'encode'; | ||
| const decode = 'decode'; | ||
|
|
||
| const normal = 'normal'; | ||
| const url = 'url'; | ||
| const hex = 'hex'; |
Contributor
|
@nbgraham Thanks for this contribution, I'm planning a revision of the autocomplete menu soon and will try to address this PR as part of or after I have completed the revision. |
|
|
7062680 to
9037697
Compare
Contributor
|
Thanks for your contribution @nbgraham I've removed the testing abstraction to keep the prod code easier to read and added a finder to the test. Removed some conditions to allow fall through to work and eliminate code. |
jackkav
approved these changes
Jan 29, 2024
jackkav
added a commit
to jackkav/insomnia
that referenced
this pull request
Mar 13, 2024
* feat: template tag to encode hex to base64 * review, flatten, simplify --------- Co-authored-by: jackkav <jackkav@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a new "kind" to the existing bae64 encoding template tag to support encoding from hex values to base 64.
I have a use-case for passing in hex strings as bytes to gRPC and the sender client expects base64 encoded strings, which makes it very difficult to test.
The diff is really not that big, I just pulled out the base64tag into it's own object so I could export it for testing. I added comments with the changed lines.