Skip to content

fix: escape quotes in enum string values #365

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

Merged
merged 3 commits into from
Nov 12, 2020
Merged

fix: escape quotes in enum string values #365

merged 3 commits into from
Nov 12, 2020

Conversation

gr2m
Copy link
Contributor

@gr2m gr2m commented Nov 12, 2020

I've run into this problem when updating to the latest GitHub schema, this PR reproduces the problem the same way. I'm looking into fixing it

fixes #256

@gr2m gr2m self-assigned this Nov 12, 2020
@codecov
Copy link

codecov bot commented Nov 12, 2020

Codecov Report

Merging #365 (e9ba34b) into main (14c0a96) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #365   +/-   ##
=======================================
  Coverage   92.91%   92.91%           
=======================================
  Files           5        5           
  Lines         268      268           
  Branches       90       90           
=======================================
  Hits          249      249           
  Misses         13       13           
  Partials        6        6           
Impacted Files Coverage Δ
src/v3.ts 96.26% <ø> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1a74e25...e9ba34b. Read the comment docs.

@gr2m gr2m marked this pull request as ready for review November 12, 2020 21:24
@gr2m gr2m changed the title 🚧 escape enum values fix: escape quotes in enum string values Nov 12, 2020
@gr2m gr2m requested a review from drwpow November 12, 2020 21:26
@@ -73,7 +73,7 @@ export default function generateTypesV3(
(node.enum as string[]).map((item) =>
typeof item === "number" || typeof item === "boolean"
? item
: `'${item}'`
: `'${item.replace(/'/g, "\\'")}'`
Copy link
Contributor

Choose a reason for hiding this comment

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

This makes sense to me. In my experience, you should never be too aggressive escaping quotes like this, as you may end up with more things escaped than anticipated.

@drwpow
Copy link
Contributor

drwpow commented Nov 12, 2020

I believe this fixes #256?

@gr2m
Copy link
Contributor Author

gr2m commented Nov 12, 2020

I believe this fixes #256?

ah yes, thanks!

@gr2m gr2m merged commit 55bc785 into main Nov 12, 2020
@gr2m gr2m deleted the update-github-schema branch November 12, 2020 22:07
@drwpow
Copy link
Contributor

drwpow commented Nov 12, 2020

2.4.1 released!

@asithade asithade mentioned this pull request Dec 30, 2020
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.

Enum value with single quote causes syntax error
2 participants