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

Trim white spaces & newlines from env vars #224

Open
wants to merge 4 commits into
base: next-release
Choose a base branch
from

Conversation

Kyle-Law
Copy link
Contributor

@Kyle-Law Kyle-Law commented Feb 25, 2022

Added .strip.gsub(/\s+/, " ") method to environment variables:
var_hash['value'].strip.gsub(/\s+/, " ")

Example:

Input:

p " space-between with space ".strip.gsub(/\s+/, " ")
p " first line \n 2nd line".strip.gsub(/\s+/, " ")
p " two newlines \n\n".strip.gsub(/\s+/, " ")

Output:

"space-between with space"
"first line 2nd line"
"two newlines"

References:
https://stackoverflow.com/questions/7106964/remove-multiple-spaces-and-new-lines-inside-of-string

Alternative:

  • there's a .squish method in rails, but not available in pure ruby script
  • .split.join(' ') does the trick as well

@Kyle-Law Kyle-Law marked this pull request as ready for review February 25, 2022 09:15
@Kyle-Law
Copy link
Contributor Author

Just realized that this PR has been staled, it's for ticket #183712,
FogBugz ticket https://t3.fogbugz.com/f/cases/10221/Trim-white-space-from-environment-variables

@paulasaurus
Copy link
Contributor

Hey @jsastrillo. Please QA this recipe by adding env vars to a v6 environment which have whitespace at the start and end, and new lines, then checking that those are stripped from the env.cloud when this version of the recipe is used.

@dvalfre dvalfre requested a review from mushyy April 20, 2022 11:17
@rupikakapoor rupikakapoor self-requested a review February 28, 2023 12:14
Copy link
Contributor

@rupikakapoor rupikakapoor left a comment

Choose a reason for hiding this comment

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

This does not solve it. Tested with overlay but white space still exists in /env.cloud

export TEST="test test   "

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.

3 participants