Skip to content

Commit cc3f949

Browse files
committed
fin su info case sensitive
1 parent 0f84c97 commit cc3f949

File tree

4 files changed

+21
-5
lines changed

4 files changed

+21
-5
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,5 @@ typings/
6060
# next.js build output
6161
.next
6262

63-
.history
63+
.history
64+
.vscode/launch.json

index.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ module.exports = {
6666

6767
stringify: function (data) {
6868
let code = ''
69-
code += (data.cognome.replace(/[^BCDFGHJKLMNPQRSTVWXYZ]/gi, '') + data.cognome.replace(/[^AEIOU]/gi, '') + 'XXX').substr(0, 3)
70-
code += (data.nome.replace(/[^BCDFGHJKLMNPQRSTVWXYZ]/gi, '') + data.nome.replace(/[^AEIOU]/gi, '') + 'XXX').substr(0, 3)
69+
code += (data.cognome.toUpperCase().replace(/[^BCDFGHJKLMNPQRSTVWXYZ]/gi, '') + data.cognome.toUpperCase().replace(/[^AEIOU]/gi, '') + 'XXX').substr(0, 3)
70+
code += (data.nome.toUpperCase().replace(/[^BCDFGHJKLMNPQRSTVWXYZ]/gi, '') + data.nome.toUpperCase().replace(/[^AEIOU]/gi, '') + 'XXX').substr(0, 3)
7171

7272
const dataNascita = moment(data.data_nascita, 'YYYY-MM-DD')
7373
code += dataNascita.format('YY')
@@ -105,7 +105,7 @@ module.exports = {
105105

106106
code += comuneNascita.codiceCatastale
107107
code += getCheckCode(code)
108-
return code
108+
return code.toUpperCase()
109109
},
110110

111111
check: function (cf) {

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@arseniosiani/cfjs",
3-
"version": "1.0.4",
3+
"version": "1.0.5",
44
"description": "Modulo nodejs che il effettua il check/creazione/parsing del Codice Fiscale italiano",
55
"main": "index.js",
66
"scripts": {

test/all_tests.js

+15
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,21 @@ describe('parse', function () {
5454
chai.assert.strictEqual(cf, 'RSSMRA72L09H501S')
5555
})
5656

57+
it('stringify anagrafica nomi lowercase', function () {
58+
const infos = {
59+
nome: 'mario',
60+
cognome: 'rossi',
61+
sesso: 'm',
62+
data_nascita: '1972-07-09',
63+
comune_nascita: 'Roma',
64+
provincia_nascita: 'RM',
65+
cap_nascita: '00118',
66+
cod_catastale_nascita: 'H501'
67+
}
68+
const cf = cfjs.stringify(infos)
69+
chai.assert.strictEqual(cf, 'RSSMRA72L09H501S')
70+
})
71+
5772
it('stringify anagrafica con solo codice catastale', function () {
5873
const infos = {
5974
nome: 'MARIO',

0 commit comments

Comments
 (0)