summaryrefslogtreecommitdiff
path: root/node_modules/locutus/php/filesystem/dirname.js
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/locutus/php/filesystem/dirname.js')
-rw-r--r--node_modules/locutus/php/filesystem/dirname.js16
1 files changed, 16 insertions, 0 deletions
diff --git a/node_modules/locutus/php/filesystem/dirname.js b/node_modules/locutus/php/filesystem/dirname.js
new file mode 100644
index 0000000..9d9c7b0
--- /dev/null
+++ b/node_modules/locutus/php/filesystem/dirname.js
@@ -0,0 +1,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 \ No newline at end of file