I got rid of this logic completely by passing in (from demux) just the basename without the extension:
```
// Get the basename without the .json extension.                               
name = libpath.basename(path, '.json');
```