Skip to content

Commit

Permalink
Fix postRules item input logic
Browse files Browse the repository at this point in the history
  • Loading branch information
mmzliveid committed Aug 6, 2019
1 parent ced597e commit 3ed2879
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions modules/ng-translit/src/translit.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,6 @@ export class TranslitService {
}
foundRule = true;
const matchedString = m[0];

if (ruleItem.parsedTo != null) {
curStr = curStr.replace(ruleItem.fromRegExp, ruleItem.parsedTo);
}
Expand All @@ -272,9 +271,10 @@ export class TranslitService {

const rightPartSize = curStr.length - matchedString.length;
const newStart = curStr.length - rightPartSize;

if (ruleItem.parsedPostRules && ruleItem.parsedTo != null && curStr.length > 0) {
curStr = this.applySubRuleItems(curStr, ruleItem.parsedPostRules, userOptions, currentTrace);
if (ruleItem.parsedPostRules && ruleItem.parsedTo != null && matchedString.length > 0) {
const subInput = matchedString.replace(ruleItem.fromRegExp, ruleItem.parsedTo);
const subReplaced = this.applySubRuleItems(subInput, ruleItem.parsedPostRules, userOptions, currentTrace);
curStr = curStr.length > subInput.length ? subReplaced + curStr.substring(subInput.length) : subReplaced;
if (currentTrace) {
const newString = outStr + curStr;
currentTrace.newString = newString;
Expand Down

0 comments on commit 3ed2879

Please sign in to comment.