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.
This commit is contained in:
Andreas Kling 2021-07-03 12:32:46 +02:00
parent 70278d57ba
commit e4a55404f1
Notes: sideshowbarker 2024-07-18 11:03:34 +09:00

View file

@ -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)