samuelgozi / firebase-auth-lite

A lightweight firebase auth alternative for the browser
MIT License
119 stars 19 forks source link

fix: Prevent trailing white space in error codes #47

Closed amoutonbrady closed 4 years ago

amoutonbrady commented 4 years ago

Some (maybe all) error messages comes with a white space before the explication of the message. The regex strips everything after : but not the space before it. One example of this is the "Too many attemps" error that yields the following:

"TOO_MANY_ATTEMPTS_TRY_LATER : Too many unsuccessful login attempts. Please try again later."

Applying your regexp it returns: "TOO_MANY_ATTEMPTS_TRY_LATER ".

I'm not sure what's more efficient between altering the regexp to handle that case or using .trim() on the final message.

samuelgozi commented 4 years ago

Thanks for the pull request. I think that altering the regex will be a better option, not necessarily because of performance(although I do think that it might be faster) but because it makes it simpler because whoever reads the code if he understands regex will expect it to be entirely handled by the regexp match.

I'll update the regexp(unless you want to take this on).

amoutonbrady commented 4 years ago

Thanks for getting back to me this quick! Please go ahead and do it, regexp can be hard to get right, I trust you more than I trust myself haha 😅

samuelgozi commented 4 years ago

No problem. I'll have this fixed today hopefully. As a side note, I highly recommend you to take these lessons if you are interested in regexp: https://laracasts.com/series/understanding-regular-expressions

EDIT: Not sponsored or anything, but it's the same lessons I took when I learned this, and he's a great teacher!

amoutonbrady commented 4 years ago

I will give it a shot, thanks for the recommendation and thank you for your reactivity, I'm glad I chose this option for my current project!