Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(#9341): strip invisible characters #9364

Merged
merged 7 commits into from
Aug 26, 2024
2 changes: 1 addition & 1 deletion api/src/services/report/smsparser.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const T_TABLE = {
// TODO ensure everything in here is still needed
const digitReplacer = c => T_TABLE[c];
const standardiseDigits = original => {
return original && original.toString().replace(/[०-९]/g, digitReplacer);
return original && stripInvisibleCharacters(original.toString().replace(/[०-९]/g, digitReplacer));
};

const isMuvukuFormat = (exports.isMuvukuFormat = msg => {
Expand Down
23 changes: 23 additions & 0 deletions api/tests/mocha/services/report/smsparser.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1670,4 +1670,27 @@ describe('sms parser', () => {
chai.expect(config.translate.callCount).to.equal(2);
});

it('should correctly parse and standardize BS Year from Devanagari digits using parseField', () => {
const bsYearField = { type: 'bsYear' };
const input = '२०८०'; // 2080 in Devanagari
const expected = '2080';
const result = smsparser.parseField(bsYearField, input, 'year');
chai.expect(result).to.equal(expected);
});

it('should correctly parse and standardize BS Month from Devanagari digits using parseField', () => {
const bsMonthField = { type: 'bsMonth' };
const input = '०४'; // 04 in Devanagari
const expected = '04';
const result = smsparser.parseField(bsMonthField, input, 'month');
chai.expect(result).to.equal(expected);
});

it('should correctly parse and standardize BS Day from Devanagari digits using parseField', () => {
const bsDayField = { type: 'bsDay' };
const input = '१५'; // 15 in Devanagari
const expected = '15';
const result = smsparser.parseField(bsDayField, input, 'day');
chai.expect(result).to.equal(expected);
});
});
Loading