Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@hapi/address

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hapi/address - npm Package Compare versions

Comparing version 2.1.2 to 3.1.0

lib/errors.js

24

lib/domain.js

@@ -5,3 +5,5 @@ 'use strict';

const Errors = require('./errors');
const internals = {

@@ -24,7 +26,7 @@ minDomainSegments: 2,

if (!domain) {
return { error: 'Domain must be a non-empty string' };
return Errors.code('DOMAIN_NON_EMPTY_STRING');
}
if (domain.length > 256) {
return { error: 'Domain too long' };
return Errors.code('DOMAIN_TOO_LONG');
}

@@ -35,3 +37,3 @@

if (options.allowUnicode === false) { // Defaults to true
return { error: 'Domain contains forbidden Unicode characters' };
return Errors.code('DOMAIN_INVALID_UNICODE_CHARS');
}

@@ -43,3 +45,3 @@

if (internals.domainControlRx.test(domain)) {
return { error: 'Domain contains invalid character' };
return Errors.code('DOMAIN_INVALID_CHARS');
}

@@ -55,3 +57,3 @@

if (segments.length < minDomainSegments) {
return { error: 'Domain lacks the minimum required number of segments' };
return Errors.code('DOMAIN_SEGMENTS_COUNT');
}

@@ -65,3 +67,3 @@

return { error: 'Domain uses forbidden TLD' };
return Errors.code('DOMAIN_FORBIDDEN_TLDS');
}

@@ -74,7 +76,7 @@ }

if (!segment.length) {
return { error: 'Domain contains empty dot-separated segment' };
return Errors.code('DOMAIN_EMPTY_SEGMENT');
}
if (segment.length > 63) {
return { error: 'Domain contains dot-separated segment that is too long' };
return Errors.code('DOMAIN_LONG_SEGMENT');
}

@@ -84,3 +86,3 @@

if (!internals.domainSegmentRx.test(segment)) {
return { error: 'Domain contains invalid character' };
return Errors.code('DOMAIN_INVALID_CHARS');
}

@@ -90,6 +92,8 @@ }

if (!internals.tldSegmentRx.test(segment)) {
return { error: 'Domain contains invalid tld character' };
return Errors.code('DOMAIN_INVALID_TLDS_CHARS');
}
}
}
return null;
};

@@ -96,0 +100,0 @@

@@ -6,2 +6,3 @@ 'use strict';

const Domain = require('./domain');
const Errors = require('./errors');

@@ -34,3 +35,3 @@

if (!email) {
return { error: 'Address must be a non-empty string' };
return Errors.code('EMPTY_STRING');
}

@@ -43,3 +44,3 @@

if (options.allowUnicode === false) { // Defaults to true
return { error: 'Address contains forbidden Unicode characters' };
return Errors.code('FORBIDDEN_UNICODE');
}

@@ -54,3 +55,3 @@

if (parts.length !== 2) {
return { error: parts.length > 2 ? 'Address cannot contain more than one @ character' : 'Address must contain one @ character' };
return parts.length > 2 ? Errors.code('MULTIPLE_AT_CHAR') : Errors.code('MISSING_AT_CHAR');
}

@@ -61,3 +62,3 @@

if (!local) {
return { error: 'Address local part cannot be empty' };
return Errors.code('EMPTY_LOCAL');
}

@@ -67,7 +68,7 @@

if (email.length > 254) { // http://tools.ietf.org/html/rfc5321#section-4.5.3.1.3
return { error: 'Address too long' };
return Errors.code('ADDRESS_TOO_LONG');
}
if (internals.encoder.encode(local).length > 64) { // http://tools.ietf.org/html/rfc5321#section-4.5.3.1.1
return { error: 'Address local part too long' };
return Errors.code('LOCAL_TOO_LONG');
}

@@ -87,3 +88,3 @@ }

if (!segment.length) {
return { error: 'Address local part contains empty dot-separated segment' };
return Errors.code('EMPTY_LOCAL_SEGMENT');
}

@@ -93,3 +94,3 @@

if (!internals.atextRx.test(segment)) {
return { error: 'Address local part contains invalid character' };
return Errors.code('INVALID_LOCAL_CHARS');
}

@@ -107,3 +108,3 @@

if (!internals.atomRx.test(binary)) {
return { error: 'Address local part contains invalid character' };
return Errors.code('INVALID_LOCAL_CHARS');
}

@@ -110,0 +111,0 @@ }

@@ -5,2 +5,3 @@ 'use strict';

const Email = require('./email');
const Errors = require('./errors');
const Tlds = require('./tlds');

@@ -15,2 +16,4 @@

module.exports = {
errors: Errors.codes,
domain: {

@@ -17,0 +20,0 @@ analyze(domain, options) {

{
"name": "@hapi/address",
"description": "Email address and domain validation",
"version": "2.1.2",
"repository": "git://github.com/hapijs/address",
"main": "lib/index.js",
"keywords": [
"email",
"domain",
"address",
"validation"
],
"dependencies": {},
"devDependencies": {
"@hapi/code": "6.x.x",
"@hapi/lab": "20.x.x"
},
"scripts": {
"test": "lab -a @hapi/code -t 100 -L",
"test-cov-html": "lab -a @hapi/code -t 100 -L -r html -o coverage.html"
},
"license": "BSD-3-Clause"
"name": "@hapi/address",
"description": "Email address and domain validation",
"version": "3.1.0",
"repository": "git://github.com/hapijs/address",
"main": "lib/index.js",
"types": "lib/index.d.ts",
"keywords": [
"email",
"domain",
"address",
"validation"
],
"files": [
"lib"
],
"dependencies": {},
"devDependencies": {
"@hapi/code": "7.x.x",
"@hapi/lab": "21.x.x"
},
"scripts": {
"test": "lab -a @hapi/code -t 100 -L -Y",
"test-cov-html": "lab -a @hapi/code -t 100 -L -r html -o coverage.html"
},
"license": "BSD-3-Clause"
}

@@ -1,7 +0,16 @@

<a href="http://hapijs.com"><img src="https://raw.githubusercontent.com/hapijs/assets/master/images/family.png" width="180px" align="right" /></a>
<a href="https://hapi.dev"><img src="https://raw.githubusercontent.com/hapijs/assets/master/images/family.png" width="180px" align="right" /></a>
# @hapi/address
Validate email address and domain
#### Validate email address and domain.
[![Build Status](https://secure.travis-ci.org/hapijs/address.svg)](http://travis-ci.org/hapijs/address)
**address** is part of the **hapi** ecosystem and was designed to work seamlessly with the [hapi web framework](https://hapi.dev) and its other components (but works great on its own or with other frameworks). If you are using a different web framework and find this module useful, check out [hapi](https://hapi.dev) � they work even better together.
### Visit the [hapi.dev](https://hapi.dev) Developer Portal for tutorials, documentation, and support
## Useful resources
- [Documentation and API](https://hapi.dev/family/address/)
- [Versions status](https://hapi.dev/resources/status/#address)
- [Project policies](https://hapi.dev/policies/)
- [Free and commercial support options](https://hapi.dev/support/)
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc