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

purify

Package Overview
Dependencies
Maintainers
2
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

purify - npm Package Compare versions

Comparing version 3.2.0 to 3.3.0

20

lib/purify.js

@@ -33,3 +33,7 @@ (function (root, factory) {

encodedDomain = fragments.length === 2 && punycode.toASCII(fragments[1]);
punycode.toUnicode(encodedDomain); // Makes sure invalid domains like foo.xn--no aren't allowed
var decodedDomain = punycode.toUnicode(encodedDomain); // Makes sure invalid domains like foo.xn--no aren't allowed
if (!(/\.[^\.]{2,}$/.test(decodedDomain))) {
encodedDomain = undefined; // Sorry, one-letter TLDs still aren't allowed
}
}

@@ -58,2 +62,6 @@ } catch (e) {

decodedDomain = fragments.length === 2 && punycode.toUnicode(fragments[1]);
if (!(/\.[^\.]{2,}$/.test(decodedDomain))) {
decodedDomain = undefined; // Sorry, one-letter TLDs still aren't allowed
}
}

@@ -78,3 +86,7 @@ } catch (e) {

encodedDomain = punycode.toASCII(rawValue.toLowerCase());
punycode.toUnicode(encodedDomain); // Makes sure that things like foo.xn--no aren't allowed
var decodedDomain = punycode.toUnicode(encodedDomain); // Makes sure that things like foo.xn--no aren't allowed
if (!(/\.[^\.]{2,}$/.test(decodedDomain))) {
encodedDomain = undefined; // Sorry, one-letter TLDs still aren't allowed
}
}

@@ -98,2 +110,6 @@ } catch (e) {

decodedDomain = punycode.toUnicode(rawValue.toLowerCase());
if (!(/\.[^\.]{2,}$/.test(decodedDomain))) {
decodedDomain = undefined; // Sorry, one-letter TLDs still aren't allowed
}
}

@@ -100,0 +116,0 @@ } catch (e) {

2

package.json

@@ -19,3 +19,3 @@ {

},
"version": "3.2.0",
"version": "3.3.0",
"engines": {

@@ -22,0 +22,0 @@ "node": ">=0.4.0"

@@ -26,1 +26,42 @@ purify

```
API
---
* `.email(rawValue, defaultValue)`
* `.emailIdn(rawValue, defaultValue)` - Returns e-mail with non-punycoded form regardless of input.
* `.domainName(rawValue, defaultValue)`
* `.domainNameIdn(rawValue, defaultValue)` - Returns domain in non-punycoded form regardless of input.
* `.url(rawValue, defaultValue)`
* `.urlWithLocalhost(rawValue, defaultValue)`
* `.integer(rawValue, defaultValue)`
* `.integerInRange(rawValue, lower, upper, defaultValue)`
* `.positiveInteger(rawValue, defaultValue)`
* `.positiveIntegerOrZero(rawValue, defaultValue)`
* `.float(rawValue, defaultValue)`
* `.positiveFloat(rawValue, defaultValue)`
* `.positiveFloatOrZero(rawValue, defaultValue)`
* `.nonEmptyVisibleUnicode(rawValue, defaultValue)`
* `.visibleUnicode(rawValue, defaultValue)`
* `.nonEmptyPrintableUnicode(rawValue, defaultValue)`
* `.printableUnicode(rawValue, defaultValue)`
* `.nonEmptyVisibleAscii(rawValue, defaultValue)`
* `.visivleAscii(rawValue, defaultValue)`
* `.nonEmptyPrintableAscii(rawValue, defaultValue)`
* `.printableAscii(rawValue, defaultValue)`
* `.alphaNumeric(rawValue, defaultValue)`
* `.nonEmptyAlphaNumeric(rawValue, defaultValue)`
* `.alphaNumericWithDot(rawValue, defaultValue)`
* `.uuid(rawValue, defaultValue)`
* `.upperCaseUuid(rawValue, defaultValue)`
* `.lowerCaseUuid(rawValue, defaultValue)`
* `.json(rawValue, defaultValue)`
Mostly, you can leave `defaultValue` empty, which will cause purify to return
`undefined` in case the value doesn't pass validation.

@@ -79,2 +79,3 @@ /*global it, describe*/

expect('email', 'not to allow', 'foo@bar.xn--no');
expect('email', 'not to allow', 'foo@bar.xn--nod');
expect('email', 'not to allow', 'andræas@centersurf.quuxbar');

@@ -103,2 +104,3 @@ });

expect('emailIdn', 'not to allow', 'foo@bar.xn--no');
expect('emailIdn', 'not to allow', 'foo@bar.xn--nod');
expect('emailIdn', 'not to allow', 'andræas@cæntersurf.quuxbar');

@@ -127,2 +129,3 @@ });

expect('domain', 'not to allow', 'bar.xn--no');
expect('domain', 'not to allow', 'bar.xn--nod');
expect('domain', 'not to allow', '/!');

@@ -151,2 +154,3 @@ });

expect('domainIdn', 'not to allow', 'bar.xn--no');
expect('domainIdn', 'not to allow', 'bar.xn--nod');
expect('domainIdn', 'not to allow', '/!');

@@ -153,0 +157,0 @@ });

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