Replace arabic numbers with engilsh ones.
Simply pass a String, Object or an Array.
var fixArabicNumbers = require('fix-arabic-numbers');
fixArabicNumbers('١٢٣٤٥٦٧٨٩٠ـ٪'); // return '1234567890_%'
fixArabicNumbers(['١', '٢', 'test ٣', 'تجربة ٤']); // return ['1', '2', 'test 3', 'تجربة 4']
fixArabicNumbers({test: '١٢٣٤'}); // return {test: '1234'}
You can use this module as a connect middleware to fix req.body
and req.query
by using fixArabicNumbers.connect
middleware
var express = require('express');
var fixArabicNumbers = require('fix-arabic-numbers');
var app = express();
app.use(bodyParser.json());
app.use(bodyParser.urlencoded());
// use connect middleware after using body-parser.
app.use(fixArabicNumbers.connect);
app.get('/', function (req, res) {
// req.body & req.query now checked and fixed.
})
req.params
are processed by express router on requrst. to fix req.params
you could use fixArabicNumbers.params
middleware
var express = require('express');
var fixArabicNumbers = require('fix-arabic-numbers');
var app = express();
app.get('/', fixArabicNumbers.params, function (req, res) {
// req.params now checked and fixed.
})