Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions dist/string.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ string.js - Copyright (C) 2012-2014, JP Richardson <jprichardson@gmail.com>
var s = this.trim().s.replace(/[_\s]+/g, '-').replace(/([A-Z])/g, '-$1').replace(/-+/g, '-').toLowerCase();
return new this.constructor(s);
},

equalsIgnoreCase: function(prefix) {
var s = this.s;
return s.toLowerCase() == prefix.toLowerCase()
Expand Down Expand Up @@ -690,14 +690,15 @@ string.js - Copyright (C) 2012-2014, JP Richardson <jprichardson@gmail.com>
return this.s;
},

//#modified from https://github.com/epeli/underscore.string
underscore: function() {
var s = this.trim().s.replace(/([a-z\d])([A-Z]+)/g, '$1_$2').replace(/([A-Z\d]+)([A-Z][a-z])/g,'$1_$2').replace(/[-\s]+/g, '_').toLowerCase();
var s = this.trim().s.replace(/([A-Z])/g, function (_, m, i) {
return (i ? '_' : '') + m.toLowerCase();
}).replace(/[\s_-]+/g, '_');
return new this.constructor(s);
},

unescapeHTML: function() { //from underscore.string
return new this.constructor(this.s.replace(/\&([^;]+);/g, function(entity, entityCode){
return new this.constructor(this.s.replace(/&([^;]{1,20});/g, function(entity, entityCode){
var match;

if (entityCode in escapeChars) {
Expand Down
9 changes: 5 additions & 4 deletions lib/string.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ string.js - Copyright (C) 2012-2014, JP Richardson <jprichardson@gmail.com>
var s = this.trim().s.replace(/[_\s]+/g, '-').replace(/([A-Z])/g, '-$1').replace(/-+/g, '-').toLowerCase();
return new this.constructor(s);
},

equalsIgnoreCase: function(prefix) {
var s = this.s;
return s.toLowerCase() == prefix.toLowerCase()
Expand Down Expand Up @@ -613,14 +613,15 @@ string.js - Copyright (C) 2012-2014, JP Richardson <jprichardson@gmail.com>
return this.s;
},

//#modified from https://github.com/epeli/underscore.string
underscore: function() {
var s = this.trim().s.replace(/([a-z\d])([A-Z]+)/g, '$1_$2').replace(/([A-Z\d]+)([A-Z][a-z])/g,'$1_$2').replace(/[-\s]+/g, '_').toLowerCase();
var s = this.trim().s.replace(/([A-Z])/g, function (_, m, i) {
return (i ? '_' : '') + m.toLowerCase();
}).replace(/[\s_-]+/g, '_');
return new this.constructor(s);
},

unescapeHTML: function() { //from underscore.string
return new this.constructor(this.s.replace(/\&([^;]+);/g, function(entity, entityCode){
return new this.constructor(this.s.replace(/&([^;]{1,20});/g, function(entity, entityCode){
var match;

if (entityCode in escapeChars) {
Expand Down