The .base64() function validates strings that contain binary information encoded in Base 64. A modification of Base 64 that can safely be used in URLs and filenames is given by the base64url standard specified in RFC 4648 § 5. As summarized here,
it uses the same algorithm as the main standard, but differs in the following:
Replaces “+” by “-” (minus)
Replaces “/” by “_” (underline)
Does not require a padding character
Forbids line separators
I propose a method .base64url() that is similar to .base64(), but instead matches against a regular expression that describes base64url-encoded values.
The
.base64()
function validates strings that contain binary information encoded in Base 64. A modification of Base 64 that can safely be used in URLs and filenames is given by thebase64url
standard specified in RFC 4648 § 5. As summarized here,I propose a method
.base64url()
that is similar to.base64()
, but instead matches against a regular expression that describesbase64url
-encoded values.