Skip to content

Commit

Permalink
[Fix] nvm_normalize_lts: error when an LTS name is not lowercase
Browse files Browse the repository at this point in the history
Fixes #3417
  • Loading branch information
ljharb committed Sep 4, 2024
1 parent 9a28dbd commit 9fb9dec
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions nvm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -891,6 +891,10 @@ nvm_normalize_lts() {
fi
;;
*)
if [ "${LTS}" != "$(echo "${LTS}" | command tr '[:upper:]' '[:lower:]')" ]; then
nvm_err 'LTS names must be lowercase'
return 3
fi
nvm_echo "${LTS}"
;;
esac
Expand Down
3 changes: 3 additions & 0 deletions test/fast/Unit tests/nvm_normalize_lts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ ACTUAL="$(nvm_normalize_lts "lts/*")"
EXPECTED='lts/*'
[ "${ACTUAL}" = "${EXPECTED}" ] || die "expected >${EXPECTED}<, got >${ACTUAL}<"

if ACTUAL="$(nvm_normalize_lts lts/ARGON)"; then
die "expected failure, got >${ACTUAL}<"
fi

MOCKS_DIR="../Unit tests/mocks"
STAR="$(cat "$MOCKS_DIR/lts-star.txt")"
Expand Down

0 comments on commit 9fb9dec

Please sign in to comment.