mirror of
https://github.com/crypto-pro-web/crypto-pro-js.git
synced 2024-11-24 00:55:00 +03:00
Merge pull request #19 from versh23/add-space-subject
add support to translation tag with space
This commit is contained in:
commit
ebeb4761e6
@ -12,7 +12,7 @@ export const ISSUER_TAGS_TRANSLATIONS: TagsTranslations[] = [
|
|||||||
{ possibleNames: ['ОГРН', 'OGRN'], translation: 'ОГРН' },
|
{ possibleNames: ['ОГРН', 'OGRN'], translation: 'ОГРН' },
|
||||||
{ possibleNames: ['ОГРНИП', 'OGRNIP'], translation: 'ОГРНИП' },
|
{ possibleNames: ['ОГРНИП', 'OGRNIP'], translation: 'ОГРНИП' },
|
||||||
{ possibleNames: ['СНИЛС', 'SNILS'], translation: 'СНИЛС' },
|
{ possibleNames: ['СНИЛС', 'SNILS'], translation: 'СНИЛС' },
|
||||||
{ possibleNames: ['ИНН', 'INN'], translation: 'ИНН' },
|
{ possibleNames: ['ИНН', 'INN', 'ИНН организации'], translation: 'ИНН' },
|
||||||
{ possibleNames: ['E'], translation: 'Email' },
|
{ possibleNames: ['E'], translation: 'Email' },
|
||||||
{ possibleNames: ['L'], translation: 'Город' },
|
{ possibleNames: ['L'], translation: 'Город' },
|
||||||
];
|
];
|
||||||
|
@ -14,7 +14,7 @@ export const SUBJECT_TAGS_TRANSLATIONS: TagsTranslations[] = [
|
|||||||
{ possibleNames: ['ОГРН', 'OGRN'], translation: 'ОГРН' },
|
{ possibleNames: ['ОГРН', 'OGRN'], translation: 'ОГРН' },
|
||||||
{ possibleNames: ['ОГРНИП', 'OGRNIP'], translation: 'ОГРНИП' },
|
{ possibleNames: ['ОГРНИП', 'OGRNIP'], translation: 'ОГРНИП' },
|
||||||
{ possibleNames: ['СНИЛС', 'SNILS'], translation: 'СНИЛС' },
|
{ possibleNames: ['СНИЛС', 'SNILS'], translation: 'СНИЛС' },
|
||||||
{ possibleNames: ['ИНН', 'INN'], translation: 'ИНН' },
|
{ possibleNames: ['ИНН', 'INN', 'ИНН организации'], translation: 'ИНН' },
|
||||||
{ possibleNames: ['E'], translation: 'Email' },
|
{ possibleNames: ['E'], translation: 'Email' },
|
||||||
{ possibleNames: ['L'], translation: 'Город' },
|
{ possibleNames: ['L'], translation: 'Город' },
|
||||||
];
|
];
|
||||||
|
@ -19,6 +19,7 @@ describe('_parseCertInfo', () => {
|
|||||||
'UNKNOWN=неизвестный тэг',
|
'UNKNOWN=неизвестный тэг',
|
||||||
'E=email@example.ru',
|
'E=email@example.ru',
|
||||||
'INN=007811514257',
|
'INN=007811514257',
|
||||||
|
'ИНН организации=007811514257',
|
||||||
'OGRN=1127847087885',
|
'OGRN=1127847087885',
|
||||||
'SNILS=11617693460',
|
'SNILS=11617693460',
|
||||||
].join(', ');
|
].join(', ');
|
||||||
@ -99,6 +100,11 @@ describe('_parseCertInfo', () => {
|
|||||||
title: 'ИНН',
|
title: 'ИНН',
|
||||||
isTranslated: true,
|
isTranslated: true,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
description: '007811514257',
|
||||||
|
title: 'ИНН',
|
||||||
|
isTranslated: true,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
description: '1127847087885',
|
description: '1127847087885',
|
||||||
title: 'ОГРН',
|
title: 'ОГРН',
|
||||||
@ -123,6 +129,7 @@ describe('_parseCertInfo', () => {
|
|||||||
'S=78 Санкт-Петербург',
|
'S=78 Санкт-Петербург',
|
||||||
'C=RU',
|
'C=RU',
|
||||||
'INN=007813317783',
|
'INN=007813317783',
|
||||||
|
'ИНН организации=007813317783',
|
||||||
'OGRN=1057810150892',
|
'OGRN=1057810150892',
|
||||||
'E=uc@sampokey.ru',
|
'E=uc@sampokey.ru',
|
||||||
].join(', ');
|
].join(', ');
|
||||||
@ -173,6 +180,11 @@ describe('_parseCertInfo', () => {
|
|||||||
title: 'ИНН',
|
title: 'ИНН',
|
||||||
isTranslated: true,
|
isTranslated: true,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
description: '007813317783',
|
||||||
|
title: 'ИНН',
|
||||||
|
isTranslated: true,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
description: '1057810150892',
|
description: '1057810150892',
|
||||||
title: 'ОГРН',
|
title: 'ОГРН',
|
||||||
|
@ -15,11 +15,11 @@ export interface TagTranslation {
|
|||||||
* @returns расшифрованная информация по отдельным тэгам
|
* @returns расшифрованная информация по отдельным тэгам
|
||||||
*/
|
*/
|
||||||
export const _parseCertInfo = (tagsTranslations: TagsTranslations[], rawInfo: string): TagTranslation[] => {
|
export const _parseCertInfo = (tagsTranslations: TagsTranslations[], rawInfo: string): TagTranslation[] => {
|
||||||
const extractedEntities: string[] = rawInfo.match(/([а-яА-Яa-zA-Z0-9.]+)=(?:("[^"]+?")|(.+?))(?:,|$)/g);
|
const extractedEntities: string[] = rawInfo.match(/([а-яА-Яa-zA-Z0-9\s.]+)=(?:("[^"]+?")|(.+?))(?:,|$)/g);
|
||||||
|
|
||||||
if (extractedEntities) {
|
if (extractedEntities) {
|
||||||
return extractedEntities.map((group) => {
|
return extractedEntities.map((group) => {
|
||||||
const segmentsMatch = group.match(/^([а-яА-Яa-zA-Z0-9.]+)=(.+?),?$/);
|
const segmentsMatch = group.trim().match(/^([а-яА-Яa-zA-Z0-9\s.]+)=(.+?),?$/);
|
||||||
let title = segmentsMatch?.[1];
|
let title = segmentsMatch?.[1];
|
||||||
// Вырезаем лишние кавычки
|
// Вырезаем лишние кавычки
|
||||||
const description = segmentsMatch?.[2]?.replace(/^"(.*)"/, '$1')?.replace(/"{2}/g, '"');
|
const description = segmentsMatch?.[2]?.replace(/^"(.*)"/, '$1')?.replace(/"{2}/g, '"');
|
||||||
|
Loading…
Reference in New Issue
Block a user