File tree 2 files changed +14
-2
lines changed
2 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -266,7 +266,7 @@ Inflector.prototype = {
266
266
return word ;
267
267
}
268
268
269
- for ( rule in this . rules . irregular ) {
269
+ for ( rule in irregular ) {
270
270
if ( lowercase . match ( rule + "$" ) ) {
271
271
substitution = irregular [ rule ] ;
272
272
@@ -275,7 +275,7 @@ Inflector.prototype = {
275
275
rule = capitalize ( rule ) ;
276
276
}
277
277
278
- return word . replace ( rule , substitution ) ;
278
+ return word . replace ( new RegExp ( rule , 'i' ) , substitution ) ;
279
279
}
280
280
}
281
281
Original file line number Diff line number Diff line change @@ -359,6 +359,18 @@ test('CamelCase and UpperCamelCase is preserved for irregular and uncountable si
359
359
assert . equal ( inflector . singularize ( 'friedRice' ) , 'friedRice' ) ;
360
360
} ) ;
361
361
362
+ test ( 'CamelCase custom irregular words' , function ( assert ) {
363
+ var inflector = new Ember . Inflector ( Ember . Inflector . defaultRules ) ;
364
+ inflector . irregular ( 'unitOfMeasure' , 'unitsOfMeasure' ) ;
365
+ inflector . irregular ( 'tipoDocumento' , 'tiposDocumento' ) ;
366
+
367
+ assert . equal ( inflector . singularize ( 'unitsOfMeasure' ) , 'unitOfMeasure' ) ;
368
+ assert . equal ( inflector . pluralize ( 'unitOfMeasure' ) , 'unitsOfMeasure' ) ;
369
+
370
+ assert . equal ( inflector . singularize ( 'tiposDocumento' ) , 'tipoDocumento' ) ;
371
+ assert . equal ( inflector . pluralize ( 'tipoDocumento' ) , 'tiposDocumento' ) ;
372
+ } ) ;
373
+
362
374
test ( 'Ember.Inflector.pluralize passes same test cases as ActiveSupport::Inflector#pluralize' , function ( assert ) {
363
375
var inflector = new Ember . Inflector ( Ember . Inflector . defaultRules ) ;
364
376
You can’t perform that action at this time.
0 commit comments