Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Fix capitalisation of zero length strings #50

Open
wants to merge 1 commit into from

1 participant

@GothAck

Capitalisation of zero length strings tried to uppercase undefined due to typeof str[0] === 'undefined', .charAt(0) fixes this by returning an empty string if the char does not exist.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 23, 2012
  1. @GothAck
This page is out of date. Refresh to see the latest.
Showing with 2 additions and 2 deletions.
  1. +2 −2 lib/filters.js
View
4 lib/filters.js
@@ -27,7 +27,7 @@ exports.last = function(obj) {
exports.capitalize = function(str){
str = String(str);
- return str[0].toUpperCase() + str.substr(1, str.length);
+ return str.charAt(0).toUpperCase() + str.substr(1, str.length);
};
/**
@@ -195,4 +195,4 @@ exports.get = function(obj, prop){
*/
exports.json = function(obj){
return JSON.stringify(obj);
-};
+};
Something went wrong with that request. Please try again.