Skip to content

isBase64URL

Verifica se uma string está codificada em Base64URL.

Sintaxe

typescript
isBase64URL(value: string): boolean

Parâmetros

NomeTipoDescrição
valuestringA string a ser verificada

Retorno

TipoDescrição
booleanRetorna true se a string estiver em formato Base64URL, caso contrário, retorna false.

Exemplo

typescript
isBase64URL("U29tZV9kYWRvLQ"); // true
isBase64URL("U29tZSBkYWRv"); // false
isBase64URL(12345); // lança TypeError

Notas

  • Lança um TypeError se o valor não for uma string.
  • Base64URL utiliza os caracteres A-Z, a-z, 0-9, _ e -.

Referências

Released under the MIT License.