diff --git a/sdk/demo/index.html b/sdk/demo/index.html
index ea27170..930dabc 100644
--- a/sdk/demo/index.html
+++ b/sdk/demo/index.html
@@ -1037,6 +1037,7 @@
if (rawName.includes(':')) {
const parts = rawName.split(':');
displayName = parts[0].trim();
+ if (!docNum && parts[1]) {
docNum = parts[1].trim();
}
}
@@ -1044,14 +1045,14 @@
const digits = docNum ? String(docNum).replace(/\D/g, '') : '';
let docFormatted = '';
if (digits.length === 14) {
- docFormatted = `CNPJ ${digits.replace(/^(\d{2})(\d{3})(\d{3})(\d{4})(\d{2})$/, '../-')}`;
+ docFormatted = 'CNPJ ' + digits.substring(0, 2) + '.' + digits.substring(2, 5) + '.' + digits.substring(5, 8) + '/' + digits.substring(8, 12) + '-' + digits.substring(12, 14);
} else if (digits.length === 11) {
- docFormatted = `CPF ${digits.replace(/^(\d{3})(\d{3})(\d{3})(\d{2})$/, '..-')}`;
+ docFormatted = 'CPF ' + digits.substring(0, 3) + '.' + digits.substring(3, 6) + '.' + digits.substring(6, 9) + '-' + digits.substring(9, 11);
} else if (docNum) {
docFormatted = docNum;
}
- const typeStr = `[${c.type || 'A1'}]`;
+ const typeStr = '[' + (c.type || 'A1') + ']';
const text = docFormatted ? `${displayName}, ${docFormatted} ${typeStr}` : `${displayName} ${typeStr}`;
opt.textContent = text;
certSelect.appendChild(opt);
@@ -1080,9 +1081,9 @@
const digits = String(rawDoc).replace(/\D/g, '');
let docStr = '';
if (digits.length === 14) {
- docStr = `CNPJ: ${digits.replace(/^(\d{2})(\d{3})(\d{3})(\d{4})(\d{2})$/, '../-')}`;
+ docStr = 'CNPJ: ' + digits.substring(0, 2) + '.' + digits.substring(2, 5) + '.' + digits.substring(5, 8) + '/' + digits.substring(8, 12) + '-' + digits.substring(12, 14);
} else if (digits.length === 11) {
- docStr = `CPF: ${digits.replace(/^(\d{3})(\d{3})(\d{3})(\d{2})$/, '..-')}`;
+ docStr = 'CPF: ' + digits.substring(0, 3) + '.' + digits.substring(3, 6) + '.' + digits.substring(6, 9) + '-' + digits.substring(9, 11);
} else {
docStr = cert.type === 'A3' ? 'Token FĂsico A3' : 'ICP-Brasil';
}