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

transform hyphens to underscores on import #7564

Merged
merged 5 commits into from
Jun 20, 2024

Conversation

jackkav
Copy link
Contributor

@jackkav jackkav commented Jun 19, 2024

In order to import variables from postman with keys such as one-two-three we need to transform them to one_two_three because our nunjucks library is expecting js object syntax, for example in a js console : (notice the color difference)

{ one_two_three: "works" }
{ one-two-three: "doesn't work" }

reviewer notes: there might be some cases where the regex doesn't work the way I expect.

the postman types and inconsistent and could be using @types/postman-collection

Related to INS-4041

@jackkav jackkav requested a review from a team June 20, 2024 06:50
@jackkav jackkav changed the title make hyphens underscores transform hyphens to underscores on import Jun 20, 2024
ihexxa
ihexxa previously approved these changes Jun 20, 2024
// Use a regular expression to find and replace the pattern
return input.replace(/\{\{([^\}]+)\}\}/g, (_, match) => {
// Replace hyphens with underscores within the match
const replaced = match.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.

nit: replaceAll might improve the performance a bit.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jackkav jackkav force-pushed the feature/ins-4041-nunjucks-bug branch from 323dc30 to dc840f2 Compare June 20, 2024 10:35
@jackkav jackkav merged commit 8bb6b47 into develop Jun 20, 2024
7 checks passed
@jackkav jackkav deleted the feature/ins-4041-nunjucks-bug branch June 20, 2024 10:36
@jackkav jackkav mentioned this pull request Jun 21, 2024
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.

None yet

3 participants