Return to Snippet

Revision: 20296
at November 11, 2009 15:20 by nate63179


Initial Code
utils.getFilenameFromUrl = function(url) {
	var charPosition = url.length;
	var positionFirstSlash;
	var currentCharacter = url.charAt(charPosition);
	var breakCharacter = '/';
	var filename;
	if (currentCharacter != breakCharacter) {
		while(currentCharacter != breakCharacter) {
			currentCharacter = url.charAt(charPosition);
			positionFirstSlash = charPosition;
			charPosition--;
		}
		filename = url.substr(positionFirstSlash + 1, url.length);
	} 
	return filename;
}

Initial URL

                                

Initial Description
Strips the filename from a url, returns null if one is not found

Initial Title
Get filename from url

Initial Tags

                                

Initial Language
JavaScript