mirror of
https://github.com/nvm-sh/nvm.git
synced 2025-08-17 11:03:44 +00:00
Compare commits
2 Commits
4913fe7415
...
87ba60ed30
Author | SHA1 | Date | |
---|---|---|---|
![]() |
87ba60ed30 | ||
![]() |
4cf9964fbd |
13
nvm.sh
13
nvm.sh
@ -120,15 +120,16 @@ nvm_download() {
|
|||||||
local CURL_COMPRESSED_FLAG=""
|
local CURL_COMPRESSED_FLAG=""
|
||||||
local CURL_HEADER_FLAG=""
|
local CURL_HEADER_FLAG=""
|
||||||
|
|
||||||
if [ -n "${NVM_AUTH_HEADER:-}" ]; then
|
if [ -n "$NVM_AUTH_HEADER" ]; then
|
||||||
sanitized_header=$(nvm_sanitize_auth_header "${NVM_AUTH_HEADER}")
|
sanitized_header=$(nvm_sanitize_auth_header "$NVM_AUTH_HEADER")
|
||||||
CURL_HEADER_FLAG="--header \"Authorization: ${sanitized_header}\""
|
CURL_HEADER_FLAG="--header \"Authorization: $sanitized_header\""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if nvm_curl_use_compression; then
|
if nvm_curl_use_compression; then
|
||||||
CURL_COMPRESSED_FLAG="--compressed"
|
CURL_COMPRESSED_FLAG="--compressed"
|
||||||
fi
|
fi
|
||||||
eval "curl -q --fail ${CURL_COMPRESSED_FLAG:-} ${CURL_HEADER_FLAG:-} $*"
|
|
||||||
|
eval "curl -q --fail ${CURL_COMPRESSED_FLAG:-} ${CURL_HEADER_FLAG:-} $@"
|
||||||
elif nvm_has "wget"; then
|
elif nvm_has "wget"; then
|
||||||
# Emulate curl with wget
|
# Emulate curl with wget
|
||||||
ARGS=$(nvm_echo "$@" | command sed -e 's/--progress-bar /--progress=bar /' \
|
ARGS=$(nvm_echo "$@" | command sed -e 's/--progress-bar /--progress=bar /' \
|
||||||
@ -151,7 +152,7 @@ nvm_download() {
|
|||||||
|
|
||||||
nvm_sanitize_auth_header() {
|
nvm_sanitize_auth_header() {
|
||||||
# Remove potentially dangerous characters
|
# Remove potentially dangerous characters
|
||||||
nvm_echo "$1" | command sed 's/[^a-zA-Z0-9:;_. -]//g'
|
echo "$1" | sed 's/[^a-zA-Z0-9:;_. -]//g'
|
||||||
}
|
}
|
||||||
|
|
||||||
nvm_has_system_node() {
|
nvm_has_system_node() {
|
||||||
|
@ -19,10 +19,9 @@ nvm_download "https://raw.githubusercontent.com/nvm-sh/nvm/HEAD/install.sh" >/de
|
|||||||
# nvm_download should pass when calling with auth header
|
# nvm_download should pass when calling with auth header
|
||||||
docker pull kennethreitz/httpbin && docker run -d --name httpbin -p 80:80 kennethreitz/httpbin
|
docker pull kennethreitz/httpbin && docker run -d --name httpbin -p 80:80 kennethreitz/httpbin
|
||||||
sleep 1 # wait for httpbin to start
|
sleep 1 # wait for httpbin to start
|
||||||
NVM_AUTH_HEADER="Bearer test-token" nvm_download "http://127.0.0.1/bearer" > /dev/null || die 'nvm_download with auth header should send correctly'
|
NVM_AUTH_HEADER="Bearer test-token"
|
||||||
|
nvm_download "http://127.0.0.1/bearer" > /dev/null || die "nvm_download unable to send auth header"
|
||||||
# nvm_download should fail when calling without auth header
|
unset NVM_AUTH_HEADER
|
||||||
nvm_download "http://127.0.0.1/bearer" > /dev/null && die 'nvm_download with no auth header should not send the header and should fail'
|
|
||||||
docker stop httpbin && docker rm httpbin
|
docker stop httpbin && docker rm httpbin
|
||||||
|
|
||||||
cleanup
|
cleanup
|
||||||
|
Loading…
x
Reference in New Issue
Block a user