Skip to content

Commit

Permalink
converted tree path to canonical form for case-insensitive comp
Browse files Browse the repository at this point in the history
  • Loading branch information
jahir-raihan committed May 9, 2024
1 parent 811c039 commit 6375e4e
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions nvm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,7 @@ else
fi
unset NVM_SCRIPT_SOURCE 2>/dev/null


nvm_tree_contains_path() {
local tree
tree="${1-}"
Expand All @@ -432,14 +433,21 @@ nvm_tree_contains_path() {
previous_pathdir="${node_path}"
local pathdir
pathdir=$(dirname "${previous_pathdir}")

# Convert tree path to canonical form for case-insensitive comparison
local tree_canonical
tree_canonical=$(cd "${tree}" && pwd -P)

while [ "${pathdir}" != '' ] && [ "${pathdir}" != '.' ] && [ "${pathdir}" != '/' ] &&
[ "${pathdir}" != "${tree}" ] && [ "${pathdir}" != "${previous_pathdir}" ]; do
[ "${pathdir}" != "${tree_canonical}" ] && [ "${pathdir}" != "${previous_pathdir}" ]; do
previous_pathdir="${pathdir}"
pathdir=$(dirname "${previous_pathdir}")
done
[ "${pathdir}" = "${tree}" ]

[ "${pathdir}" = "${tree_canonical}" ]
}


nvm_find_project_dir() {
local path_
path_="${PWD}"
Expand Down

0 comments on commit 6375e4e

Please sign in to comment.