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

fix(embed): escape dollar symbol of JSON string literal #21

Merged
merged 2 commits into from
Jun 15, 2024

Conversation

Jumpaku
Copy link
Contributor

@Jumpaku Jumpaku commented Jun 14, 2024

With the original version, embed.dart cannot generate a compilable Dart code if the source JSON has a string literal containing a dollar symbol ($). For example, the following code will be generated from {"dollar": "$"}:

const _$variable = (dollar: "$");
// the string literal "$" is not valid, which is a beginning of string interpolation.

In the revised version, I fixed it to generate the following code from that JSON:

const _$variable = (dollar: "\$");
// $ is escaped!

I also added a test case.

@fujidaiti
Copy link
Owner

Hi @Jumpaku,

Nice work, thank you!

@fujidaiti fujidaiti merged commit 7bc9b51 into fujidaiti:master Jun 15, 2024
1 check failed
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.

2 participants