├── .editorconfig ├── .eslintrc.json ├── .gitattributes ├── .gitignore ├── .travis.yml ├── .verb.md ├── LICENSE ├── README.md ├── index.js ├── package.json └── test.js /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = space 5 | end_of_line = lf 6 | charset = utf-8 7 | indent_size = 2 8 | trim_trailing_whitespace = true 9 | insert_final_newline = true 10 | 11 | [{**/{actual,fixtures,expected,templates}/**,*.md}] 12 | trim_trailing_whitespace = false 13 | insert_final_newline = false -------------------------------------------------------------------------------- /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "ecmaFeatures": { 3 | "modules": true, 4 | "experimentalObjectRestSpread": true 5 | }, 6 | 7 | "env": { 8 | "browser": false, 9 | "es6": true, 10 | "node": true, 11 | "mocha": true 12 | }, 13 | 14 | "globals": { 15 | "document": false, 16 | "navigator": false, 17 | "window": false 18 | }, 19 | 20 | "rules": { 21 | "accessor-pairs": 2, 22 | "arrow-spacing": [2, { "before": true, "after": true }], 23 | "block-spacing": [2, "always"], 24 | "brace-style": [2, "1tbs", { "allowSingleLine": true }], 25 | "comma-dangle": [2, "never"], 26 | "comma-spacing": [2, { "before": false, "after": true }], 27 | "comma-style": [2, "last"], 28 | "constructor-super": 2, 29 | "curly": [2, "multi-line"], 30 | "dot-location": [2, "property"], 31 | "eol-last": 2, 32 | "eqeqeq": [2, "allow-null"], 33 | "generator-star-spacing": [2, { "before": true, "after": true }], 34 | "handle-callback-err": [2, "^(err|error)$" ], 35 | "indent": [2, 2, { "SwitchCase": 1 }], 36 | "key-spacing": [2, { "beforeColon": false, "afterColon": true }], 37 | "keyword-spacing": [2, { "before": true, "after": true }], 38 | "new-cap": [2, { "newIsCap": true, "capIsNew": false }], 39 | "new-parens": 2, 40 | "no-array-constructor": 2, 41 | "no-caller": 2, 42 | "no-class-assign": 2, 43 | "no-cond-assign": 2, 44 | "no-const-assign": 2, 45 | "no-control-regex": 2, 46 | "no-debugger": 2, 47 | "no-delete-var": 2, 48 | "no-dupe-args": 2, 49 | "no-dupe-class-members": 2, 50 | "no-dupe-keys": 2, 51 | "no-duplicate-case": 2, 52 | "no-empty-character-class": 2, 53 | "no-eval": 2, 54 | "no-ex-assign": 2, 55 | "no-extend-native": 2, 56 | "no-extra-bind": 2, 57 | "no-extra-boolean-cast": 2, 58 | "no-extra-parens": [2, "functions"], 59 | "no-fallthrough": 2, 60 | "no-floating-decimal": 2, 61 | "no-func-assign": 2, 62 | "no-implied-eval": 2, 63 | "no-inner-declarations": [2, "functions"], 64 | "no-invalid-regexp": 2, 65 | "no-irregular-whitespace": 2, 66 | "no-iterator": 2, 67 | "no-label-var": 2, 68 | "no-labels": 2, 69 | "no-lone-blocks": 2, 70 | "no-mixed-spaces-and-tabs": 2, 71 | "no-multi-spaces": 2, 72 | "no-multi-str": 2, 73 | "no-multiple-empty-lines": [2, { "max": 1 }], 74 | "no-native-reassign": 0, 75 | "no-negated-in-lhs": 2, 76 | "no-new": 2, 77 | "no-new-func": 2, 78 | "no-new-object": 2, 79 | "no-new-require": 2, 80 | "no-new-wrappers": 2, 81 | "no-obj-calls": 2, 82 | "no-octal": 2, 83 | "no-octal-escape": 2, 84 | "no-proto": 0, 85 | "no-redeclare": 2, 86 | "no-regex-spaces": 2, 87 | "no-return-assign": 2, 88 | "no-self-compare": 2, 89 | "no-sequences": 2, 90 | "no-shadow-restricted-names": 2, 91 | "no-spaced-func": 2, 92 | "no-sparse-arrays": 2, 93 | "no-this-before-super": 2, 94 | "no-throw-literal": 2, 95 | "no-trailing-spaces": 0, 96 | "no-undef": 2, 97 | "no-undef-init": 2, 98 | "no-unexpected-multiline": 2, 99 | "no-unneeded-ternary": [2, { "defaultAssignment": false }], 100 | "no-unreachable": 2, 101 | "no-unused-vars": [2, { "vars": "all", "args": "none" }], 102 | "no-useless-call": 0, 103 | "no-with": 2, 104 | "one-var": [0, { "initialized": "never" }], 105 | "operator-linebreak": [0, "after", { "overrides": { "?": "before", ":": "before" } }], 106 | "padded-blocks": [0, "never"], 107 | "quotes": [2, "single", "avoid-escape"], 108 | "radix": 2, 109 | "semi": [2, "always"], 110 | "semi-spacing": [2, { "before": false, "after": true }], 111 | "space-before-blocks": [2, "always"], 112 | "space-before-function-paren": [2, "never"], 113 | "space-in-parens": [2, "never"], 114 | "space-infix-ops": 2, 115 | "space-unary-ops": [2, { "words": true, "nonwords": false }], 116 | "spaced-comment": [0, "always", { "markers": ["global", "globals", "eslint", "eslint-disable", "*package", "!", ","] }], 117 | "use-isnan": 2, 118 | "valid-typeof": 2, 119 | "wrap-iife": [2, "any"], 120 | "yoda": [2, "never"] 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Enforce Unix newlines 2 | * text eol=lf 3 | 4 | # binaries 5 | *.ai binary 6 | *.psd binary 7 | *.jpg binary 8 | *.gif binary 9 | *.png binary 10 | *.jpeg binary 11 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # always ignore files 2 | *.DS_Store 3 | *.sublime-* 4 | 5 | # test related, or directories generated by tests 6 | test/actual 7 | actual 8 | coverage 9 | .nyc* 10 | 11 | # npm 12 | node_modules 13 | npm-debug.log 14 | 15 | # yarn 16 | yarn.lock 17 | yarn-error.log 18 | 19 | # misc 20 | _gh_pages 21 | _draft 22 | _drafts 23 | bower_components 24 | vendor 25 | temp 26 | tmp 27 | TODO.md 28 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | language: node_js 3 | node_js: 4 | - stable 5 | - node 6 | - '7' 7 | - '6' 8 | - '5' 9 | - '4' 10 | - '0.12' 11 | - '0.10' 12 | matrix: 13 | fast_finish: true 14 | allow_failures: [] 15 | -------------------------------------------------------------------------------- /.verb.md: -------------------------------------------------------------------------------- 1 | ## Usage 2 | 3 | ```js 4 | var parse = require('{%= name %}'); 5 | ``` 6 | 7 | ## Supported formats 8 | 9 | Works with a flexible range of formats, any of the properties can be used or missing: 10 | 11 | ``` 12 | Name 13 | Name (url) 14 | Name (url) 15 | Name (url) 16 | Name(url) 17 | Name (url) 18 | Name (url) 19 | Name(url) 20 | Name(url) 21 | Name (url) 22 | Name(url) 23 | Name 24 | Name 25 | (url) 26 | (url) 27 | (url) 28 | (url) 29 | 30 | (url) 31 | ``` 32 | 33 | ## Examples 34 | 35 | ```js 36 | var author = parse('Jon Schlinkert (https://github.com/jonschlinkert)'); 37 | console.log(author); 38 | //=> {name: 'Jon Schlinkert', email: 'jon.schlinkert@sellside.com', url: 'https://github.com/jonschlinkert'} 39 | 40 | console.log(parse('Jon Schlinkert (https://github.com/jonschlinkert)')); 41 | //=> {name: 'Jon Schlinkert', url: 'https://github.com/jonschlinkert'} 42 | 43 | console.log(parse('Jon Schlinkert ')); 44 | //=> {name: 'Jon Schlinkert', email: 'jon.schlinkert@sellside.com'} 45 | 46 | console.log(parse('')); 47 | //=> {} 48 | ``` 49 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014-2017, Jon Schlinkert 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # parse-author [![NPM version](https://img.shields.io/npm/v/parse-author.svg?style=flat)](https://www.npmjs.com/package/parse-author) [![NPM monthly downloads](https://img.shields.io/npm/dm/parse-author.svg?style=flat)](https://npmjs.org/package/parse-author) [![NPM total downloads](https://img.shields.io/npm/dt/parse-author.svg?style=flat)](https://npmjs.org/package/parse-author) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/parse-author.svg?style=flat&label=Travis)](https://travis-ci.org/jonschlinkert/parse-author) 2 | 3 | > Parse a string into an object with `name`, `email` and `url` properties following npm conventions. Useful for the `authors` property in package.json or for parsing an AUTHORS file into an array of authors objects. 4 | 5 | ## Install 6 | 7 | Install with [npm](https://www.npmjs.com/): 8 | 9 | ```sh 10 | $ npm install --save parse-author 11 | ``` 12 | 13 | ## Usage 14 | 15 | ```js 16 | var parse = require('parse-author'); 17 | ``` 18 | 19 | ## Supported formats 20 | 21 | Works with a flexible range of formats, any of the properties can be used or missing: 22 | 23 | ``` 24 | Name 25 | Name (url) 26 | Name (url) 27 | Name (url) 28 | Name(url) 29 | Name (url) 30 | Name (url) 31 | Name(url) 32 | Name(url) 33 | Name (url) 34 | Name(url) 35 | Name 36 | Name 37 | (url) 38 | (url) 39 | (url) 40 | (url) 41 | 42 | (url) 43 | ``` 44 | 45 | ## Examples 46 | 47 | ```js 48 | var author = parse('Jon Schlinkert (https://github.com/jonschlinkert)'); 49 | console.log(author); 50 | //=> {name: 'Jon Schlinkert', email: 'jon.schlinkert@sellside.com', url: 'https://github.com/jonschlinkert'} 51 | 52 | console.log(parse('Jon Schlinkert (https://github.com/jonschlinkert)')); 53 | //=> {name: 'Jon Schlinkert', url: 'https://github.com/jonschlinkert'} 54 | 55 | console.log(parse('Jon Schlinkert ')); 56 | //=> {name: 'Jon Schlinkert', email: 'jon.schlinkert@sellside.com'} 57 | 58 | console.log(parse('')); 59 | //=> {} 60 | ``` 61 | 62 | ## About 63 | 64 | ### Related projects 65 | 66 | * [author-regex](https://www.npmjs.com/package/author-regex): Regular expression for parsing an `author` string into an object following npm conventions. | [homepage](https://github.com/jonschlinkert/author-regex "Regular expression for parsing an `author` string into an object following npm conventions.") 67 | * [parse-authors](https://www.npmjs.com/package/parse-authors): Parse a string into an array of objects with `name`, `email` and `url` properties following… [more](https://github.com/jonschlinkert/parse-authors) | [homepage](https://github.com/jonschlinkert/parse-authors "Parse a string into an array of objects with `name`, `email` and `url` properties following npm conventions. Useful for the `authors` property in package.json or for parsing an AUTHORS file into an array of authors objects.") 68 | * [stringify-author](https://www.npmjs.com/package/stringify-author): Stringify an authors object to `name (url)`. | [homepage](https://github.com/jonschlinkert/stringify-author "Stringify an authors object to `name (url)`.") 69 | * [stringify-authors](https://www.npmjs.com/package/stringify-authors): Converts an author object or array of author objects into an array of strings. Useful… [more](https://github.com/jonschlinkert/stringify-authors) | [homepage](https://github.com/jonschlinkert/stringify-authors "Converts an author object or array of author objects into an array of strings. Useful for adding authors, maintainers or contributors to documentation, package.json or a readme.") 70 | 71 | ### Contributing 72 | 73 | Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new). 74 | 75 | ### Contributors 76 | 77 | | **Commits** | **Contributor** | 78 | | --- | --- | 79 | | 14 | [slang800](https://github.com/slang800) | 80 | | 12 | [jonschlinkert](https://github.com/jonschlinkert) | 81 | | 1 | [MitMaro](https://github.com/MitMaro) | 82 | 83 | ### Building docs 84 | 85 | _(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_ 86 | 87 | To generate the readme, run the following command: 88 | 89 | ```sh 90 | $ npm install -g verbose/verb#dev verb-generate-readme && verb 91 | ``` 92 | 93 | ### Running tests 94 | 95 | Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command: 96 | 97 | ```sh 98 | $ npm install && npm test 99 | ``` 100 | 101 | ### Author 102 | 103 | **Jon Schlinkert** 104 | 105 | * [github/jonschlinkert](https://github.com/jonschlinkert) 106 | * [twitter/jonschlinkert](https://twitter.com/jonschlinkert) 107 | 108 | ### License 109 | 110 | Copyright © 2017, [Jon Schlinkert](https://github.com/jonschlinkert). 111 | Released under the [MIT License](LICENSE). 112 | 113 | *** 114 | 115 | _This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.4.3, on March 08, 2017._ -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * parse-author 3 | * 4 | * Copyright (c) 2014-2017, Jon Schlinkert. 5 | * Released under the MIT License. 6 | */ 7 | 8 | 'use strict'; 9 | 10 | var regex = require('author-regex'); 11 | 12 | module.exports = function(str) { 13 | if (typeof str !== 'string') { 14 | throw new TypeError('expected author to be a string'); 15 | } 16 | 17 | if (!str || !/\w/.test(str)) { 18 | return {}; 19 | } 20 | 21 | var match = [].concat.apply([], regex().exec(str)); 22 | var author = {}; 23 | 24 | if (match[1]) { 25 | author.name = match[1]; 26 | } 27 | 28 | for (var i = 2; i < match.length; i++) { 29 | var val = match[i]; 30 | 31 | if (i % 2 === 0 && val && match[i + 1]) { 32 | if (val.charAt(0) === '<') { 33 | author.email = match[i + 1]; 34 | i++; 35 | 36 | } else if (val.charAt(0) === '(') { 37 | author.url = match[i + 1]; 38 | i++; 39 | } 40 | } 41 | } 42 | return author; 43 | }; 44 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "parse-author", 3 | "description": "Parse an author, contributor, maintainer or other 'person' string into an object with name, email and url properties following npm conventions.", 4 | "version": "2.0.0", 5 | "homepage": "https://github.com/jonschlinkert/parse-author", 6 | "author": "Jon Schlinkert (https://github.com/jonschlinkert)", 7 | "contributors": [ 8 | "Jon Schlinkert (http://twitter.com/jonschlinkert)", 9 | "Sean Lang (http://slang.cx)", 10 | "Tim Oram (http://www.mitmaro.ca)" 11 | ], 12 | "repository": "jonschlinkert/parse-author", 13 | "bugs": { 14 | "url": "https://github.com/jonschlinkert/parse-author/issues" 15 | }, 16 | "license": "MIT", 17 | "files": [ 18 | "index.js" 19 | ], 20 | "main": "index.js", 21 | "engines": { 22 | "node": ">=0.10.0" 23 | }, 24 | "scripts": { 25 | "test": "mocha" 26 | }, 27 | "dependencies": { 28 | "author-regex": "^1.0.0" 29 | }, 30 | "devDependencies": { 31 | "mocha": "^3.2.0" 32 | }, 33 | "keywords": [ 34 | "author", 35 | "authors", 36 | "contributor", 37 | "exec", 38 | "expression", 39 | "extract", 40 | "maintainer", 41 | "maintainers", 42 | "match", 43 | "package", 44 | "parse", 45 | "person", 46 | "pkg", 47 | "re", 48 | "regex", 49 | "regexp", 50 | "regular", 51 | "somebody" 52 | ], 53 | "verb": { 54 | "run": true, 55 | "toc": false, 56 | "layout": "default", 57 | "tasks": [ 58 | "readme" 59 | ], 60 | "plugins": [ 61 | "gulp-format-md" 62 | ], 63 | "related": { 64 | "list": [ 65 | "author-regex", 66 | "parse-authors", 67 | "stringify-author", 68 | "stringify-authors" 69 | ] 70 | }, 71 | "reflinks": [ 72 | "verb" 73 | ], 74 | "lint": { 75 | "reflinks": true 76 | } 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /test.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * parse-author 3 | * 4 | * Copyright (c) 2014-2017, Jon Schlinkert. 5 | * Released under the MIT License. 6 | */ 7 | 8 | 'use strict'; 9 | 10 | require('mocha'); 11 | var assert = require('assert'); 12 | var author = require('./'); 13 | 14 | describe('parse-author', function() { 15 | describe('empty', function() { 16 | it('should return an empty object when no matches are found', function() { 17 | assert.deepEqual(author(''), {}); 18 | }); 19 | 20 | it('should not fail on empty url placeholders', function() { 21 | assert.deepEqual(author(' ()'), {}); 22 | assert.deepEqual(author('Jon Schlinkert ()'), {name: 'Jon Schlinkert'}); 23 | assert.deepEqual(author('Jon Schlinkert ()'), { 24 | name: 'Jon Schlinkert', 25 | email: 'jon.schlinkert@sellside.com' 26 | }); 27 | 28 | assert.deepEqual(author(' ()'), { 29 | email: 'jon.schlinkert@sellside.com' 30 | }); 31 | }); 32 | 33 | it('should not fail on empty email placeholders', function() { 34 | assert.deepEqual(author('<>'), {}); 35 | assert.deepEqual(author('Jon Schlinkert <>'), {name: 'Jon Schlinkert'}); 36 | assert.deepEqual(author('<> (https://github.com/jonschlinkert)'), { 37 | url: 'https://github.com/jonschlinkert' 38 | }); 39 | }); 40 | 41 | it('should not fail on empty email and url placeholders', function() { 42 | assert.deepEqual(author('<> ()'), {}); 43 | }); 44 | }); 45 | 46 | describe('name', function() { 47 | it('should parse name only', function() { 48 | assert.deepEqual(author('Jon Schlinkert'), {name: 'Jon Schlinkert'}); 49 | }); 50 | 51 | it('should work with leading or trailing whitespace', function() { 52 | assert.deepEqual(author(' Jon Schlinkert'), {name: 'Jon Schlinkert'}); 53 | assert.deepEqual(author('Jon Schlinkert '), {name: 'Jon Schlinkert'}); 54 | assert.deepEqual(author(' Jon Schlinkert '), {name: 'Jon Schlinkert'}); 55 | }); 56 | }); 57 | 58 | describe('email', function() { 59 | it('should parse email only', function() { 60 | var fixture = ''; 61 | assert.deepEqual(author(fixture), {email: 'jon.schlinkert@sellside.com'}); 62 | }); 63 | 64 | it('should parse email with leading or trailing whitespace', function() { 65 | assert.deepEqual(author(' '), {email: 'jon.schlinkert@sellside.com'}); 66 | assert.deepEqual(author(' '), {email: 'jon.schlinkert@sellside.com'}); 67 | assert.deepEqual(author(' '), {email: 'jon.schlinkert@sellside.com'}); 68 | }); 69 | }); 70 | 71 | describe('url', function() { 72 | it('should parse url only', function() { 73 | var fixture = '(https://github.com/jonschlinkert)'; 74 | assert.deepEqual(author(fixture), {url: 'https://github.com/jonschlinkert'}); 75 | }); 76 | 77 | it('should parse url with leading or trailing whitespace', function() { 78 | assert.deepEqual(author(' (https://github.com/jonschlinkert)'), {url: 'https://github.com/jonschlinkert'}); 79 | assert.deepEqual(author('(https://github.com/jonschlinkert) '), {url: 'https://github.com/jonschlinkert'}); 80 | assert.deepEqual(author(' (https://github.com/jonschlinkert) '), {url: 'https://github.com/jonschlinkert'}); 81 | }); 82 | }); 83 | 84 | describe('name and url', function() { 85 | it('should parse name and url only', function() { 86 | var fixture = 'Jon Schlinkert (https://github.com/jonschlinkert)'; 87 | assert.deepEqual(author(fixture), { 88 | name: 'Jon Schlinkert', 89 | url: 'https://github.com/jonschlinkert' 90 | }); 91 | }); 92 | }); 93 | 94 | describe('name and email', function() { 95 | it('should parse name and email only', function () { 96 | var fixture = 'Jon Schlinkert '; 97 | var actual = author(fixture); 98 | assert.deepEqual(author(fixture), { 99 | name: 'Jon Schlinkert', 100 | email: 'jon.schlinkert@sellside.com' 101 | }); 102 | }); 103 | 104 | it('should parse name and email with leading whitespace', function () { 105 | var fixture = ' Jon Schlinkert '; 106 | var actual = author(fixture); 107 | assert.deepEqual(author(fixture), { 108 | name: 'Jon Schlinkert', 109 | email: 'jon.schlinkert@sellside.com' 110 | }); 111 | }); 112 | 113 | it('should parse name and email with trailing whitespace', function () { 114 | var fixture = 'Jon Schlinkert '; 115 | var actual = author(fixture); 116 | assert.deepEqual(author(fixture), { 117 | name: 'Jon Schlinkert', 118 | email: 'jon.schlinkert@sellside.com' 119 | }); 120 | }); 121 | 122 | it('should parse name and email with leading and trailing whitespace', function () { 123 | var fixture = ' Jon Schlinkert '; 124 | var actual = author(fixture); 125 | assert.deepEqual(author(fixture), { 126 | name: 'Jon Schlinkert', 127 | email: 'jon.schlinkert@sellside.com' 128 | }); 129 | }); 130 | }); 131 | 132 | describe('name, email and url', function() { 133 | it('should parse name, email and url', function() { 134 | var fixture = 'Jon Schlinkert (https://github.com/jonschlinkert)'; 135 | assert.deepEqual(author(fixture), { 136 | name: 'Jon Schlinkert', 137 | email: 'jon.schlinkert@sellside.com', 138 | url: 'https://github.com/jonschlinkert' 139 | }); 140 | }); 141 | 142 | it('should parse name, email and url when email has no leading whitespace', function() { 143 | var fixture = 'Jon Schlinkert (https://github.com/jonschlinkert)'; 144 | assert.deepEqual(author(fixture), { 145 | name: 'Jon Schlinkert', 146 | email: 'jon.schlinkert@sellside.com', 147 | url: 'https://github.com/jonschlinkert' 148 | }); 149 | }); 150 | 151 | it('should parse name, email and url when url has no leading whitespace', function() { 152 | var fixture = 'Jon Schlinkert (https://github.com/jonschlinkert)'; 153 | assert.deepEqual(author(fixture), { 154 | name: 'Jon Schlinkert', 155 | email: 'jon.schlinkert@sellside.com', 156 | url: 'https://github.com/jonschlinkert' 157 | }); 158 | }); 159 | 160 | it('should parse name, email and url with no separating whitespace', function() { 161 | var fixture = 'Jon Schlinkert(https://github.com/jonschlinkert)'; 162 | assert.deepEqual(author(fixture), { 163 | name: 'Jon Schlinkert', 164 | email: 'jon.schlinkert@sellside.com', 165 | url: 'https://github.com/jonschlinkert' 166 | }); 167 | }); 168 | }); 169 | 170 | describe('email and url only', function() { 171 | it('should parse email and url only', function() { 172 | var fixture = ' (https://github.com/jonschlinkert)'; 173 | assert.deepEqual(author(fixture), { 174 | email: 'jon.schlinkert@sellside.com', 175 | url: 'https://github.com/jonschlinkert' 176 | }); 177 | }); 178 | 179 | it('should parse email and url with leading whitespace', function() { 180 | var fixture = ' (https://github.com/jonschlinkert)'; 181 | assert.deepEqual(author(fixture), { 182 | email: 'jon.schlinkert@sellside.com', 183 | url: 'https://github.com/jonschlinkert' 184 | }); 185 | }); 186 | 187 | it('should parse email and url with trailing whitespace', function() { 188 | var fixture = ' (https://github.com/jonschlinkert) '; 189 | assert.deepEqual(author(fixture), { 190 | email: 'jon.schlinkert@sellside.com', 191 | url: 'https://github.com/jonschlinkert' 192 | }); 193 | }); 194 | 195 | it('should parse email and url with leading and trailing whitespace', function() { 196 | var fixture = ' (https://github.com/jonschlinkert) '; 197 | assert.deepEqual(author(fixture), { 198 | email: 'jon.schlinkert@sellside.com', 199 | url: 'https://github.com/jonschlinkert' 200 | }); 201 | }); 202 | 203 | it('should parse email and url with no separating whitespace', function() { 204 | var fixture = '(https://github.com/jonschlinkert)'; 205 | assert.deepEqual(author(fixture), { 206 | email: 'jon.schlinkert@sellside.com', 207 | url: 'https://github.com/jonschlinkert' 208 | }); 209 | }); 210 | }); 211 | 212 | describe('misordered properties', function() { 213 | it('should support misordered url and email properties', function() { 214 | var fixture = 'Jon Schlinkert (https://github.com/jonschlinkert) '; 215 | assert.deepEqual(author(fixture), { 216 | name: 'Jon Schlinkert', 217 | email: 'jon.schlinkert@sellside.com', 218 | url: 'https://github.com/jonschlinkert' 219 | }); 220 | }); 221 | 222 | it('should support misordered url and email properties only', function() { 223 | var fixture = '(https://github.com/jonschlinkert) '; 224 | assert.deepEqual(author(fixture), { 225 | email: 'jon.schlinkert@sellside.com', 226 | url: 'https://github.com/jonschlinkert' 227 | }); 228 | }); 229 | }); 230 | }); 231 | --------------------------------------------------------------------------------