From 0aaa992c1ceed0927bebbdbfaf7c095acccb289b Mon Sep 17 00:00:00 2001 From: Tim Schumacher Date: Thu, 27 May 2021 13:52:13 +0200 Subject: [PATCH] LexicalPath: Reset dirname if it's empty dirname ends up empty if the canonical path only contains one element. Reset it to the default for relative/absolute paths if that is the case. --- AK/LexicalPath.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/AK/LexicalPath.cpp b/AK/LexicalPath.cpp index b810ba24626..2e1035396b9 100644 --- a/AK/LexicalPath.cpp +++ b/AK/LexicalPath.cpp @@ -68,6 +68,10 @@ void LexicalPath::canonicalize() } m_dirname = dirname_builder.to_string(); + if (m_dirname.is_empty()) { + m_dirname = m_is_absolute ? "/" : "."; + } + m_basename = canonical_parts.last(); Optional last_dot = StringView(m_basename).find_last_of('.');