Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
_.getDir() #underscore #mixin #cc
_.mixin({
// - Returns the directory of a url or full path
// Source: https://gist.github.com/tracend/31436d82befafab96d15
getDir: function ( url ) {
// prerequisite
if( typeof url != "string" ) return "";
//
var location = url.match(/^.*[\\\/]/);
// return if there are any matches...
return ( location !== null ) ? location[0] : "";
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment