That would almost work, but you have to be careful with the special cases, where `ext` may or may not be empty, and may or may not be "." prefixed. And you have to make sure all return paths are statically type compatible.

But this would (AFAIK) work:
```D
path = stripExtension(path);

if (ext.empty || ext.front() == '.')
   return chain(path, "", ext);
else
   return chain(path, ".", ext);
```