emberjs / emberjs/ember-inflector

Irregular inflector behavior

Open
#110 4 comments 1 reaction 0 assignees View on GitHub
Dominant language
TypeScript
Stars
107
Forks
78
Avg merge
20h 58m
Merged PRs (30d)
4

Description

Hello there,

I have these rules (among others) in my app.

``` javascript
inflector.irregular('arma-branca', 'armas-brancas');
inflector.irregular('acessorio-arma-branca', 'acessorios-armas-brancas');
```

With this config I get this result:
![selection_006](https://cloud.githubusercontent.com/assets/9344/19283422/1da774fe-8fc8-11e6-9d05-79bf2ab6d8d4.png)

It seems the second irregular rule is never met, this [line](https://github.com/stefanpenner/ember-inflector/blob/master/addon/lib/system/inflector.js#L270) looks like the culprit. It checks for the end of the rule, so, strings ending the same way can respond wrongly.

Another thing I notice is that this code makes the irregular declaration order specific. If I invert the order like so:

``` javascript
inflector.irregular('acessorio-arma-branca', 'acessorios-armas-brancas');
inflector.irregular('arma-branca', 'armas-brancas');
```

I get the right result:
![selection_007](https://cloud.githubusercontent.com/assets/9344/19283514/8c2e2350-8fc8-11e6-84b9-53f0c9d2a1f1.png)

Can we make the irregulars check for the whole expression first?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.