Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a string.base64() method. #1016

Merged
merged 3 commits into from
Nov 6, 2016
Merged

Added a string.base64() method. #1016

merged 3 commits into from
Nov 6, 2016

Conversation

chris--young
Copy link
Contributor

Just like string.hex() but for base64

@@ -376,6 +376,20 @@ internals.String = class extends Any {
});
}

base64() {

const regex = /^[a-z0-9\+\/]+(=+)?$/i;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This regex doesn't seem to be good enough, there are few provided in http://stackoverflow.com/questions/475074/regex-to-parse-or-validate-base64-data, https://github.com/kevva/base64-regex seems quite good, don't think he'd be offended if we took it from him.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh cool, I'll switch that out and add in some more unit tests. I had a feeling there might be some weird paddings that could sneak through.

@Marsup Marsup added the feature New functionality or improvement label Nov 3, 2016
@Marsup Marsup self-assigned this Nov 3, 2016
@Marsup Marsup added this to the 10.0.0 milestone Nov 6, 2016
@Marsup Marsup merged commit 36df2aa into hapijs:master Nov 6, 2016
@lock
Copy link

lock bot commented Jan 9, 2020

This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions.

@lock lock bot locked as resolved and limited conversation to collaborators Jan 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature New functionality or improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants