From e4a55404f18ce785068aab710c7dbb33f10d226b Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 3 Jul 2021 12:32:46 +0200 Subject: [PATCH] LibCore: Avoid duplicate '/' in DirIterator::next_full_path() When the root path of a DirIterator ends with '/', we don't need to add another '/' before appending the file name. Fixes an issue where files found by Assistant had 2 leading slashes. --- Userland/Libraries/LibCore/DirIterator.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Userland/Libraries/LibCore/DirIterator.cpp b/Userland/Libraries/LibCore/DirIterator.cpp index deb3f17d04..adbc3c1418 100644 --- a/Userland/Libraries/LibCore/DirIterator.cpp +++ b/Userland/Libraries/LibCore/DirIterator.cpp @@ -77,7 +77,12 @@ String DirIterator::next_path() String DirIterator::next_full_path() { - return String::formatted("{}/{}", m_path, next_path()); + StringBuilder builder; + builder.append(m_path); + if (!m_path.ends_with('/')) + builder.append('/'); + builder.append(next_path()); + return builder.to_string(); } String find_executable_in_path(String filename)