Skip to content

Commit a5d9f29

Browse files
committed
.
0 parents  commit a5d9f29

10 files changed

+235
-0
lines changed

.editorconfig

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# editorconfig.org
2+
root = true
3+
4+
[*]
5+
indent_style = space
6+
indent_size = 2
7+
end_of_line = lf
8+
charset = utf-8
9+
trim_trailing_whitespace = true
10+
insert_final_newline = true
11+
12+
[*.md]
13+
trim_trailing_whitespace = false

.eslintrc

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"env": {
3+
"node": true
4+
},
5+
"rules": {
6+
// warnings
7+
"no-unused-expressions": 1,
8+
"no-warning-comments": 1,
9+
"no-native-reassign": 1,
10+
"no-invalid-regexp": 1,
11+
"no-debugger": 1,
12+
"no-console": 1,
13+
"no-empty": 1,
14+
"radix": 1,
15+
16+
// errors
17+
"no-shadow-restricted-names": 2,
18+
"handle-callback-err": 2,
19+
"no-self-compare": 2,
20+
"no-empty-class": 2,
21+
"no-unused-vars": 2,
22+
"no-dupe-keys": 2,
23+
"valid-typeof": 2,
24+
"no-undef": 2,
25+
26+
// stylistic errors
27+
"quotes": [2, "single", "avoid-escape"],
28+
"no-space-before-semi": 2,
29+
"space-unary-word-ops": 2,
30+
"no-spaced-func": 2,
31+
"yoda": "always",
32+
"new-cap": 2,
33+
34+
// mute
35+
"no-use-before-define": 0,
36+
"eol-last": 0,
37+
"strict": 0,
38+
"eqeqeq": 0,
39+
"curly": 0
40+
}
41+
}

.gitignore

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# tmp files
2+
lib-cov
3+
*.seed
4+
*.log
5+
*.csv
6+
*.dat
7+
*.out
8+
*.pid
9+
*.gz
10+
11+
# tmp folders
12+
pids/
13+
logs/
14+
results/
15+
coverage/
16+
17+
# node.js
18+
node_modules/
19+
npm-debug.log
20+
21+
# osx
22+
.DS_Store

.travis.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
node_js:
2+
- "0.10"
3+
- "0.11"
4+
language: node_js
5+
script: "make test-travis"
6+
after_script: "npm install coveralls@2 && cat ./coverage/lcov.info | coveralls"

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2014
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 all
13+
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 THE
21+
SOFTWARE.

Makefile

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
SRC = index.js
2+
3+
include node_modules/make-lint/index.mk
4+
5+
LINT_CONFIG = .eslintrc
6+
TESTS = test.js
7+
8+
test: lint
9+
@NODE_ENV=test ./node_modules/.bin/mocha \
10+
--require should \
11+
$(TESTS) \
12+
--bail
13+
14+
test-cov:
15+
@NODE_ENV=test node \
16+
node_modules/.bin/istanbul cover \
17+
./node_modules/.bin/_mocha \
18+
-- -u exports \
19+
--require should \
20+
$(TESTS) \
21+
--bail
22+
23+
test-travis:
24+
@NODE_ENV=test node \
25+
node_modules/.bin/istanbul cover \
26+
./node_modules/.bin/_mocha \
27+
--report lcovonly \
28+
-- -u exports \
29+
--require should \
30+
$(TESTS) \
31+
--bail
32+
33+
.PHONY: test

README.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# regex-email
2+
[![NPM version][npm-image]][npm-url]
3+
[![build status][travis-image]][travis-url]
4+
[![Test coverage][coveralls-image]][coveralls-url]
5+
[![Downloads][downloads-image]][downloads-url]
6+
7+
Regular expression for email.
8+
9+
## Installation
10+
```bash
11+
$ npm install regex-email
12+
```
13+
14+
## Usage
15+
```js
16+
var regex = require('regex-utc-date');
17+
18+
regex.test('[email protected]');
19+
// => true
20+
```
21+
22+
## See Also
23+
- [Update your Email RegExp][ddiaz] by [Dustin Diaz](https://github.com/ded)
24+
25+
## License
26+
[MIT](https://tldrlegal.com/license/mit-license)
27+
28+
[npm-image]: https://img.shields.io/npm/v/regex-email.svg?style=flat-square
29+
[npm-url]: https://npmjs.org/package/regex-email
30+
[travis-image]: https://img.shields.io/travis/regexps/regex-email.svg?style=flat-square
31+
[travis-url]: https://travis-ci.org/regexps/regex-email
32+
[coveralls-image]: https://img.shields.io/coveralls/regexps/regex-email.svg?style=flat-square
33+
[coveralls-url]: https://coveralls.io/r/regexps/regex-email?branch=master
34+
[downloads-image]: http://img.shields.io/npm/dm/regex-email.svg?style=flat-square
35+
[downloads-url]: https://npmjs.org/package/regex-email
36+
37+
[ddiaz]: (http://www.dustindiaz.com/update-your-email-regexp/)

index.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/**
2+
* Expose email regex.
3+
*
4+
* Example input:
5+
6+
7+
8+
*/
9+
10+
module.exports = /^([\w_\.\-\+])+\@([\w\-]+\.)+([\w]{2,10})+$/;

package.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"name": "regex-email",
3+
"version": "1.0.0",
4+
"description": "Regular expression for email",
5+
"main": "index.js",
6+
"scripts": {
7+
"test": "make test"
8+
},
9+
"repository": "regexps/regex-email",
10+
"keywords": [
11+
"regular expression",
12+
"regexp",
13+
"regex",
14+
"email"
15+
],
16+
"license": "MIT",
17+
"dependencies": {},
18+
"devDependencies": {
19+
"istanbul": "^0.3.5",
20+
"make-lint": "^1.0.1",
21+
"mocha": "^2.0.1"
22+
},
23+
"files": [
24+
"README.md",
25+
"LICENSE",
26+
"index.js"
27+
]
28+
}

test.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/**
2+
* Module dependencies
3+
*/
4+
5+
var assert = require('assert');
6+
var regex = require('./');
7+
8+
/**
9+
* Test
10+
*/
11+
12+
describe('email regex', function() {
13+
it('should match email input', function() {
14+
assert.equal(regex.test('[email protected]'), true);
15+
assert.equal(regex.test('[email protected]'), true);
16+
assert.equal(regex.test('[email protected]'), true);
17+
});
18+
19+
it('should catch incorrect input', function() {
20+
assert.equal(regex.test('*(*(*()))'), false);
21+
assert.equal(regex.test('foobar@@hello.com'), false);
22+
assert.equal(regex.test('[email protected]'), false);
23+
});
24+
});

0 commit comments

Comments
 (0)