diff --git a/src/platform/platform.cpp b/src/platform/platform.cpp index f025c861..00854131 100644 --- a/src/platform/platform.cpp +++ b/src/platform/platform.cpp @@ -185,8 +185,10 @@ Path Path::WithExtension(std::string ext) const { if(dot != std::string::npos) { withExt.raw.erase(dot); } - withExt.raw += "."; - withExt.raw += ext; + if(!ext.empty()) { + withExt.raw += "."; + withExt.raw += ext; + } return withExt; } diff --git a/test/core/path/test.cpp b/test/core/path/test.cpp index 92639564..86accf1f 100644 --- a/test/core/path/test.cpp +++ b/test/core/path/test.cpp @@ -83,6 +83,7 @@ TEST_CASE(extension) { } TEST_CASE(with_extension) { + CHECK_EQ_STR(Path::From("foo.bar").WithExtension("").raw, "foo"); CHECK_EQ_STR(Path::From("foo.bar").WithExtension("baz").raw, "foo.baz"); CHECK_EQ_STR(Path::From("foo").WithExtension("baz").raw, "foo.baz"); }