From c72f2c6f21fbee8e0d3c8088f9ce1a0620fd5e07 Mon Sep 17 00:00:00 2001 From: Dena Burd Date: Thu, 24 Sep 2020 13:46:29 -0700 Subject: [PATCH] [Fix] `nvm ls-remote`: accept versions that end with a dot Fixes #983. --- nvm.sh | 4 ++++ test/fast/Unit tests/nvm_ls_remote | 13 +++++++++++++ 2 files changed, 17 insertions(+) diff --git a/nvm.sh b/nvm.sh index 6a9b7f4..cfb29cc 100644 --- a/nvm.sh +++ b/nvm.sh @@ -1240,6 +1240,10 @@ nvm_ls_remote_index_tab() { local PATTERN PATTERN="${3-}" + if [ "${PATTERN#"${PATTERN%?}"}" = '.' ]; then + PATTERN="${PATTERN%.}" + fi + local VERSIONS if [ -n "${PATTERN}" ] && [ "${PATTERN}" != '*' ]; then if [ "${FLAVOR}" = 'iojs' ]; then diff --git a/test/fast/Unit tests/nvm_ls_remote b/test/fast/Unit tests/nvm_ls_remote index 2171650..be61cc4 100755 --- a/test/fast/Unit tests/nvm_ls_remote +++ b/test/fast/Unit tests/nvm_ls_remote @@ -40,6 +40,19 @@ v0.3.8" [ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm_ls_remote 0.3 did not output 0.3.x versions; got $OUTPUT" +OUTPUT="$(nvm_ls_remote 0.3.)" +EXPECTED_OUTPUT="v0.3.0 +v0.3.1 +v0.3.2 +v0.3.3 +v0.3.4 +v0.3.5 +v0.3.6 +v0.3.7 +v0.3.8" + +[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm_ls_remote 0.3. did not output 0.3.x versions; got $OUTPUT" + # Sanity checks OUTPUT="$(nvm_print_implicit_alias remote stable)" EXPECTED_OUTPUT_PATH="${MOCKS_DIR}/nvm_print_implicit_alias remote stable.txt"