summaryrefslogtreecommitdiff
path: root/node_modules/locutus/php/filesystem/dirname.js
blob: 9d9c7b07e3234254319a1c06f8411515741235de (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
'use strict';

module.exports = function dirname(path) {
  //  discuss at: http://locutus.io/php/dirname/
  // original by: Ozh
  // improved by: XoraX (http://www.xorax.info)
  //   example 1: dirname('/etc/passwd')
  //   returns 1: '/etc'
  //   example 2: dirname('c:/Temp/x')
  //   returns 2: 'c:/Temp'
  //   example 3: dirname('/dir/test/')
  //   returns 3: '/dir'

  return path.replace(/\\/g, '/').replace(/\/[^/]*\/?$/, '');
};
//# sourceMappingURL=dirname.js.map