fix dir match

This commit is contained in:
jxxghp 2024-05-29 17:28:49 +08:00
parent 8a4202cee5
commit f7ca4abb01

View File

@ -1,3 +1,4 @@
import os
from pathlib import Path
from typing import List, Optional
@ -128,7 +129,7 @@ class DirectoryHelper:
for matched_dir in matched_dirs:
try:
# 计算in_path和path的公共字符串长度
relative_len = len(StringUtils.find_common_prefix(str(in_path), matched_dir.path))
relative_len = len(StringUtils.find_common_prefix(str(in_path), str(Path(matched_dir.path))))
if len(str(matched_dir.path)) == relative_len \
and relative_len >= max_length:
# 目录完整匹配且是最长的,直接返回