parse-author 0.1.1

Parse an npm-style author string "Name <email> (url)" into its name, email, and url. A faithful port of the parse-author npm package. Zero dependencies, no_std.
Documentation
  • Coverage
  • 100%
    6 out of 6 items documented2 out of 3 items with examples
  • Size
  • Source code size: 28.14 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 187.27 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 2s Average build duration of successful builds.
  • all releases: 2s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • trananhtung/parse-author
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • trananhtung

parse-author

All Contributors

Crates.io Documentation CI License

Parse an npm-style author string"Name <email> (url)" — into its name, email, and url. The format used by package.json author/contributors fields. A faithful Rust port of the parse-author npm package (and the author-regex it is built on). Zero dependencies and #![no_std].

use parse_author::parse_author;

let a = parse_author("Jon Schlinkert <jon@example.com> (https://github.com/jonschlinkert)");
assert_eq!(a.name.as_deref(), Some("Jon Schlinkert"));
assert_eq!(a.email.as_deref(), Some("jon@example.com"));
assert_eq!(a.url.as_deref(), Some("https://github.com/jonschlinkert"));

assert_eq!(parse_author("Jane Doe").name.as_deref(), Some("Jane Doe"));
assert_eq!(parse_author("<me@example.com>").email.as_deref(), Some("me@example.com"));

Why parse-author?

Tooling that reads package.json — license checkers, SBOM generators, registry mirrors, JS-build-tool ports — needs to pull the name, email, and homepage out of an author string. The shape is simple but has corners (each part optional, brackets decide the field), and this matches the canonical JS parser exactly.

[dependencies]
parse-author = "0.1"

API

Item Purpose
parse_author(input) Parse into an Author
Author { name, email, url } Each an Option<String>, present only when found

Behavior

  • The name is everything before the first < or (, trimmed.
  • A <…> segment is the email; a (…) segment is the url (the opening bracket decides the field — <…) still parses as an email).
  • An input with no word character, or one that doesn't fit the Name <email> (url) shape (an unterminated bracket, trailing junk), yields an empty Author.

Contributors ✨

This project follows the all-contributors specification. Contributions of any kind are welcome — code, docs, bug reports, ideas, reviews! See the emoji key for how each contribution is recognized, and open a PR or issue to get involved.

Thanks goes to these wonderful people:

License

Licensed under either of Apache-2.0 or MIT at your option.