How to trim a file extension from a String in JavaScript?
Not sure what would perform faster but this would be more reliable when it comes to extension like .jpeg
or .html
x.replace(/\.[^/.]+$/, "")
In node.js, the name of the file without the extension can be obtained as follows.
const path = require('path');
const filename = 'hello.html';
path.parse(filename).name; //=> "hello"
path.parse(filename).ext; //=> ".html"
path.parse(filename).base; //=> "hello.html"
Further explanation at Node.js documentation page.