Last active
August 29, 2015 14:04
-
-
Save tracend/31436d82befafab96d15 to your computer and use it in GitHub Desktop.
_.getDir() #underscore #mixin #cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_.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