Skip to content

Instantly share code, notes, and snippets.

@nopjia
Created September 25, 2015 00:29
Show Gist options
  • Save nopjia/bf710eb34a00f355f307 to your computer and use it in GitHub Desktop.
Save nopjia/bf710eb34a00f355f307 to your computer and use it in GitHub Desktop.
basename & dirname
var basename = function(path) {
return path.replace(/\\/g, "/").replace( /.*\//, "");
};
var dirname = function(path) {
return path.replace(/\\/g, "/").replace(/\/[^\/]*$/, "");
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment