Base64 icon indicating copy to clipboard operation
Base64 copied to clipboard

Add support for RFC 4648 compatible URL-safe encoding

Open jnschulze opened this issue 11 years ago • 4 comments

jnschulze avatar Feb 18 '13 20:02 jnschulze

Hi j.n. thanks for the pull request.

I think the URL-safe encoding could actually be more simply implemented as a post-processing step (find and replace of + and / with - and _ respectively after conversion).

Can you explain what the use case for the noPad option is?

nicklockwood avatar Feb 18 '13 20:02 nicklockwood

OK I read RFC4648 and it explains why you might want to strip the padding.

nicklockwood avatar Feb 18 '13 21:02 nicklockwood

Hi Nick, As replacing the characters as a post-processing step would require another loop for string processing, I wanted to improve efficiency by avoiding the (negligible) overhead. The noPad option prevents the encoder from adding the padding character (=). But as this option might not be that useful, it should just depend on the urlSafe option.

regards, Niklas

jnschulze avatar Feb 18 '13 21:02 jnschulze

Thank you, that makes sense.

I'd like to change the interface a bit and I'm not happy with the duplication of the lookup table (not very DRY) so I'd like to do some performance tests to see if the benefit is significant, but I'll look into implementing equivalent functionality in the next release. Thanks again.

nicklockwood avatar Feb 18 '13 21:02 nicklockwood