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

Add falsy-allowing variable replace #268

Closed
fredrikhr opened this issue May 2, 2022 · 2 comments
Closed

Add falsy-allowing variable replace #268

fredrikhr opened this issue May 2, 2022 · 2 comments

Comments

@fredrikhr
Copy link
Contributor

There are several cases I have encountered that the replaced text from a variable replacer ended up being falsy (e.g. empty string). Because the output of the variable replacer is falsy, httpyac uses the original template string verbatim, instead of replacing it with an empty string.

Common scenarios where I have encountered this is when prompting for user input for e.g. a query parameter that legally accepts empty strings.

I do however realize that there might be other issues with simply replacing falsy values. Maybe we could add a new syntax for falsy-forgiving replacement? E.g. {{? falsyExpression }}. And maybe just modifying the javascript expression replacer is already good enough.

@AnWeber
Copy link
Owner

AnWeber commented May 2, 2022

That an empty string was not allowed here is an error. I think it should work correctly without new syntax. Only the substitution of boolean would currently not be converted correctly as string, but rather only because I would not know which value to use (true vs 1 vs yes).

@fredrikhr
Copy link
Contributor Author

Great! Okay, then we can close this 👍

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

No branches or pull requests

2 participants