don't crash when uppercasing an empty string
All checks were successful
PR Check / lint-and-format (pull_request) Successful in 18s

This commit is contained in:
Mylloon 2024-10-08 20:38:24 +02:00
parent fc189ab552
commit d3251fd50a
Signed by: Anri
GPG key ID: A82D63DFF8D1317F

View file

@ -12,5 +12,9 @@ declare global {
/** Capitalize definition */ /** Capitalize definition */
String.prototype.capitalize = function (this: string) { String.prototype.capitalize = function (this: string) {
if (this.length === 0) {
return this;
}
return this[0].toUpperCase() + this.substring(1); return this[0].toUpperCase() + this.substring(1);
}; };