Skip to content

Commit

Permalink
Fix dot-files validation: #59
Browse files Browse the repository at this point in the history
Signed-off-by: Tsuyoshi Hombashi <tsuyoshi.hombashi@gmail.com>
  • Loading branch information
thombashi committed Jan 3, 2025
1 parent 1ff515b commit 2312adc
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pathvalidate/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ def sanitize(self, value: PathType, replacement_text: str = "") -> PathType: #

class BaseValidator(AbstractValidator):
__RE_ROOT_NAME: Final = re.compile(r"([^\.]+)")
__RE_REPEAD_DOT: Final = re.compile(r"^\.{3,}")

@property
def min_len(self) -> int:
Expand Down Expand Up @@ -238,6 +239,12 @@ def _validate_max_len(self) -> None:

@classmethod
def __extract_root_name(cls, path: str) -> str:
if path in (".", ".."):
return path

if cls.__RE_REPEAD_DOT.search(path):
return path

match = cls.__RE_ROOT_NAME.match(os.path.basename(path))
if match is None:
return ""
Expand Down

0 comments on commit 2312adc

Please sign in to comment.