Node.js ci fornisce una valida soluzione per il parsing dei percorsi dei file.
La soluzione รจ la seguente:
var path = require('path');
var myFilePath = '/directory/file.json';
path.parse(myFilePath).base === 'file.json'; // true
path.parse(myFilePath).name === 'file'; // true
path.parse(myFilePath).ext === '.json'; // true