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

Sanitize empty strings when getting Proxy Environment variables #92

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions lib/tailwind.ex
Original file line number Diff line number Diff line change
Expand Up @@ -319,11 +319,24 @@ defmodule Tailwind do
end

defp proxy_for_scheme("http") do
System.get_env("HTTP_PROXY") || System.get_env("http_proxy")
get_and_sanitize_env_var("HTTP_PROXY") || get_and_sanitize_env_var("http_proxy")
end

defp proxy_for_scheme("https") do
System.get_env("HTTPS_PROXY") || System.get_env("https_proxy")
get_and_sanitize_env_var("HTTPS_PROXY") || get_and_sanitize_env_var("https_proxy")
end

defp get_and_sanitize_env_var(env_var) do
trimmed =
case System.get_env(env_var) do
nil -> nil
x -> String.trim(x)
end

case trimmed do
"" -> nil
_ -> trimmed
end
end

defp maybe_add_proxy_auth(http_options, scheme) do
Expand Down