Skip to content

Commit

Permalink
la funcion format ya no devuelve - cuando se pasa un string vacio
Browse files Browse the repository at this point in the history
  • Loading branch information
jlobos committed Apr 16, 2024
1 parent 9af7f2e commit a35e1a4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
3 changes: 3 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ function validate (rut) {
function format (rut, options = {
dots: true
}) {
// If the input is not a string, return an empty string
if (!rut) { return '' }

rut = clean(rut)

let result
Expand Down
1 change: 1 addition & 0 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ test('format', (t) => {
t.is(format('189726317', { dots: false }), '18972631-7')
t.is(format('18*972*631*7', { dots: false }), '18972631-7')
t.is(format('9068826-k', { dots: false }), '9068826-K')
t.is(format(''), '')
})

test('does not validate rut with 0 on most right digit', t => {
Expand Down

0 comments on commit a35e1a4

Please sign in to comment.