`singularize()` incorrectly lops off the beginning of dasherized, irregularly pluralized words
ultimatedelman opened this issue · 12 comments
This is a problem when you have a model named something like "in-common-person", where in place of "person", any member of the irregularPairs list is at the end of the dasherized list.
To repro:
Ember.String.singularize('in-common-person') // 'common-person'
Ember.String.singularize('in-common-man') // 'common-man'
//etc.
Because of this, any model named in this way is improperly referenced.
@OFbriggs got any free time to take a look?
I'll investigate...
@OFbriggs thank you kindly :)
I believe the error is here. In the first flow, it's only returning the last part where as in the second flow it's appending the beginning part as well.
@stefanpenner of course :)
@ultimatedelman I'm having trouble reproducing the cut. The area you're referring to appears valid, because that case is for a hard match. Can you help me out and give me a failing case?
@OFbriggs - did you try the examples I gave in the ticket?
Ember.String.singularize('in-common-person') // 'common-person' instead of 'in-common-person'
@OFbriggs - I managed to cobble together a working demo
@ultimatedelman I tried the examples, for me running the functions yield:
Ember.String.singularize('in-common-person') => 'in-common-person`
The ember.js in the demo is not using an up-to-date inflector it seems.
Neither is Canary. I can't reproduce this inside of ember-inflector's tests, but can here: http://emberjs.jsbin.com/faguwohagu/1/edit?html,js,output
Okay, this is an issue that existed previously, was present in Ember Data 1.0-beta16.1, and has since been updated in beta 17. Updated the JSBin, and now it works. This is safe to close.
Thanks @nathanhammond :)
thanks all for digging into this :)