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

lib/string: added parseDomain and parseEmail #27648

Closed
wants to merge 1 commit into from

Conversation

taktoa
Copy link
Member

@taktoa taktoa commented Jul 25, 2017

Motivation for this change

This adds two functions to lib.strings: parseDomain and parseEmail, which parse domains and emails under RFC 1035 and RFC 5322 respectively (the email parser accepts a superset of what is allowed under RFC 5322, but the domain parser should be tight).

I found myself in need of functions to parse domains and emails, so I thought I would upstream what I wrote.

Things done
  • Tested on platform(s)
    • NixOS
    • macOS
    • Linux
  • Definition has associated documentation.
  • Implemented unit tests in lib/tests/misc.nix.
  • Successfully ran nix-build lib/tests/release.nix.
  • Fits CONTRIBUTING.md.

@mention-bot
Copy link

@taktoa, thanks for your PR! By analyzing the history of the files in this pull request, we identified @edolstra, @zimbatm and @Profpatsch to be potential reviewers.

b = builtins;
regex = "^([^.@][^@]*[^.@]|[^.@])@([^.@][^@]*[^.@]|[^.@])$";
matched = b.match regex email;
mayFail = b.tryEval (
Copy link
Member

Choose a reason for hiding this comment

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

Please don't use tryEval, it's a horrible function with poorly specified semantics that are not a good match for a purely functional language. It seems to me that an if-then-else would work just as well as a series of assertions.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll remove it. Couldn't resist the Maybe monad style that it allows 😄

@matthewbauer
Copy link
Member

Ping on status?

@taktoa
Copy link
Member Author

taktoa commented Apr 21, 2018

Sorry I haven't been working on this; I'm pretty busy with my senior thesis until May 10th.
If you need this between now and then for some reason and are willing to finish up this PR, just send me a patch and I'll git commit --amend it on (or I can give you the commit bit on my nixpkgs fork).

@aanderse
Copy link
Member

@taktoa any motivation to continue with this PR?

@taktoa taktoa closed this May 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants