@agencebio/rosetta-cultures
Advanced tools
Comparing version 1.7.0 to 1.7.1
@@ -105,5 +105,9 @@ "use strict"; | ||
var _a; | ||
if (typeof code !== 'string') { | ||
return null; | ||
} | ||
var cleanCode = code.trim().replace(/\s+/g, ' '); | ||
return (_a = cpf_json_1.default.find(function (_a) { | ||
var codes_geofolia = _a.codes_geofolia; | ||
return codes_geofolia.includes(code); | ||
return codes_geofolia.includes(cleanCode); | ||
})) !== null && _a !== void 0 ? _a : null; | ||
@@ -110,0 +114,0 @@ } |
@@ -95,3 +95,8 @@ /** | ||
export function fromCodeGeofolia (code) { | ||
return cpf.find(({ codes_geofolia }) => codes_geofolia.includes(code)) ?? null | ||
if (typeof code !== 'string') { | ||
return null | ||
} | ||
const cleanCode = code.trim().replace(/\s+/g, ' ') | ||
return cpf.find(({ codes_geofolia }) => codes_geofolia.includes(cleanCode)) ?? null | ||
} | ||
@@ -98,0 +103,0 @@ |
@@ -127,2 +127,11 @@ import { describe, it } from 'node:test' | ||
}) | ||
it('returns a single matching code, even with multiple spaces', () => { | ||
deepEqual(fromCodeGeofolia('ZAR ZFB').code_cpf, '01.11.12') | ||
deepEqual(fromCodeGeofolia('ZAR ZFB').code_cpf, '01.11.12') | ||
deepEqual(fromCodeGeofolia('ZAQ ZFA').code_cpf, '01.11.11') | ||
deepEqual(fromCodeGeofolia('ZAQ ZFA').code_cpf, '01.11.11') | ||
deepEqual(fromCodeGeofolia('ZAR ZFAI01').code_cpf, '01.11.12') | ||
deepEqual(fromCodeGeofolia('ZAR ZFAI01').code_cpf, '01.11.12') | ||
}) | ||
}) | ||
@@ -129,0 +138,0 @@ |
{ | ||
"name": "@agencebio/rosetta-cultures", | ||
"version": "1.7.0", | ||
"version": "1.7.1", | ||
"description": "Traduction des codes cultures de la CPF vers la PAC vers des nomenclatures d'organismes de certification, et vice-versa.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1922574
63857