-
Notifications
You must be signed in to change notification settings - Fork 55
Add dataUri and dataUriToString functions
#1332
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
base: main
Are you sure you want to change the base?
Add dataUri and dataUriToString functions
#1332
Conversation
bf06fc1 to
aa04b78
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This pull request adds two new DSC configuration functions: dataUri() and dataUriToString(). The dataUri() function converts a string to a base64-encoded data URI format, while dataUriToString() performs the inverse operation by decoding a data URI back to its original string.
Changes:
- Added
dataUri()function to convert strings to data URI format with base64 encoding - Added
dataUriToString()function to decode base64-encoded data URIs back to strings - Included comprehensive unit tests and integration tests for both functions
- Added documentation with examples for both functions
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 14 comments.
Show a summary per file
| File | Description |
|---|---|
| lib/dsc-lib/src/functions/mod.rs | Registered the new data_uri and data_uri_to_string modules in alphabetical order |
| lib/dsc-lib/src/functions/data_uri.rs | Implemented dataUri() function that encodes strings as base64 data URIs with application/json media type |
| lib/dsc-lib/src/functions/data_uri_to_string.rs | Implemented dataUriToString() function that decodes base64-encoded data URIs to strings with UTF-8 validation |
| lib/dsc-lib/locales/en-us.toml | Added localization strings for function descriptions and error messages |
| dsc/tests/dsc_functions.tests.ps1 | Added comprehensive PowerShell integration tests covering normal operation, error cases, and edge cases |
| docs/reference/schemas/config/functions/overview.md | Added references to the new functions in the string functions section |
| docs/reference/schemas/config/functions/dataUri.md | Added documentation for dataUri() function with examples and parameter descriptions |
| docs/reference/schemas/config/functions/dataUriToString.md | Added documentation for dataUriToString() function with examples and exception details |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if *part == "base64" { | ||
| has_base64 = true; | ||
| } else if part.starts_with("charset=") { | ||
| charset_count += 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of having charset_count, you should just check if charset.is_some() (after renaming charset_value to just charset since it'd be the only variable)
PR Summary
This pull request adds the
dataUrianddataUriToStringfunctions, including tests and documentation.PR Context
Partially addresses #57.