- correct pathExtension and stringByDeletingPathExtension

This commit is contained in:
Emmanuel Maillard authored and Ross Boucher committed 2010-03-27 13:23:55 -07:00
1 parent 33f56bb203
commit 65a669a9a1
1 file changed
+8 -2
+8 -2
View File
@@ -664,6 +664,8 @@ var CPStringRegexSpecialCharacters = [
*/
- (CPString)pathExtension
{
if (lastIndexOf('.') == CPNotFound)
return "";
return substr(lastIndexOf('.') + 1);
}
@@ -701,11 +703,15 @@ var CPStringRegexSpecialCharacters = [
/*!
Deletes the extension of a string.
This method assumes that the string's contents is the path to a file or just a filename.
*/
- (CPString)stringByDeletingPathExtension
{
return substr(0, [self length] - ([self pathExtension].length + 1));
var extension = [self pathExtension];
if (extension === "")
return [self copy];
if (lastIndexOf('.') < 1)
return [self copy];
return substr(0, [self length] - (extension.length + 1));
}
- (CPString)stringByStandardizingPath