Socket
Socket
Sign inDemoInstall

string-sanitizer

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

string-sanitizer - npm Package Compare versions

Comparing version 2.0.1 to 2.0.2

10

index.js

@@ -43,4 +43,2 @@ 'use strict';

// Add Fullstop, Underscore & Dash without sanitizing
exports.addFullstop = function (str) {

@@ -76,3 +74,2 @@ return str.replace(/ /g, '.');

const regex = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
// return regex.test(str);
if (regex.test(str)) {

@@ -87,3 +84,2 @@ return str;

const regex = /^[a-z][a-z]+\d*$|^[a-z]\d{2,}$/i;
// return regex.test(str);
if (regex.test(str)) {

@@ -96,8 +92,5 @@ return str.toLowerCase();

// Password Validation
// To check a password between 6 to 15 characters which contain at least one numeric digit and a special character
exports.validate.isPassword6to15 = function (str) {
const regex = /^(?=.*[0-9])(?=.*[!@#$%^&*])[a-zA-Z0-9!@#$%^&*]{6,15}$/;
// return regex.test(str);
if (regex.test(str)) {

@@ -113,3 +106,2 @@ return str;

const regex = /^[A-Za-z]\w{7,20}$/;
// return regex.test(str);
if (regex.test(str)) {

@@ -125,3 +117,2 @@ return str;

const regex = /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{6,20}$/;
// return regex.test(str);
if (regex.test(str)) {

@@ -138,3 +129,2 @@ return str;

/^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[^a-zA-Z0-9])(?!.*\s).{8,15}$/;
// return regex.test(str);
if (regex.test(str)) {

@@ -141,0 +131,0 @@ return str;

5

package.json

@@ -5,3 +5,3 @@ {

"description": "An intuitive & tiny string sanitizer to remove any special characters or convert strings to create filename or url 🎉🎉",
"version": "2.0.1",
"version": "2.0.2",
"main": "node.js",

@@ -13,2 +13,5 @@ "repository": "github:fazlulkarimweb/string-sanitizer",

"string validator",
"email validator",
"username validator",
"password validator",
"string filename",

@@ -15,0 +18,0 @@ "remove special characters",

65

readme.md
# String Sanitizer
An intuitive & tiny string sanitizer to remove any special characters or convert strings to create filename or url 🎉🎉
An intuitive & tiny string sanitizer to remove any special characters or convert strings to create filename or url. Validate email, password & username too. 🎉🎉
#### Version 2 with no breaking changes
2.0.0 is launched with major updates. Pull requests are welcome. Everything is tested. Email, password and username validation is added.
# Use Case
> **✅ Update:** 2.0.0 is launched with major updates. No breaking changes. Email, password and username validation is added. Everything is tested.
Converting or sanitizing string is easier than ever with the help of this package. You can use this utility package to sanitize even foreign languages other than English. Under the hood, regex is heavily used in this library. You can convert your string to url or filename frindly string.
## Use Case
Converting or sanitizing string is easier than ever with the help of this package. You can use this utility package to sanitize even foreign languages other than English. Under the hood, regex is heavily used in this library. You can convert your string to url or filename frindly string. Besides you can validate email, passwords and username too.
🎉🎉

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

# Sanitization Use Cases
## Sanitization use cases

@@ -58,13 +58,14 @@ ```js

## Santization Use Case
**✅ Screenshot**
![string-sanitizer](https://i.ibb.co/y44bXBb/Screenshot-275.png)
## Validation (Added in version 2.00)
Most of the time we have to validate email, password and username in our codebase. So string sanitizer starts offering validation. You pass your user generated email, username or password in this method. If it passed the checking, it will return the string as it is. If it doesn't pass the filtering, it will return false.
# Validation 👀👀👀
**Added in version 2.0.0**
if you pass your email, username or password.
Most of the time we have to validate email, password and username in our codebase. So string sanitizer starts offering validation along with sanitization. You pass your user generated email, username or password in this method. If it passes the filter, it will return the string as it is. If it doesn't pass the filter, it will return false.
### Email Validation
## Email Validation ✅
```js

@@ -79,3 +80,4 @@ var string = require("string-sanitizer");

### Username Validation
## Username Validation ✅
Username must be free from any special characters. There will be no space and must be at least 2 characters long. Combination of numbers and letters is acceptable. Only numbers (i.e 123) are not acceptable. But only letters (i.e ea) wil be acceptable.

@@ -100,40 +102,49 @@

### Password Validation
## Password Validation ✅
#### To check a password between 6 to 15 characters which contain at least one numeric digit and a special character (Most popular)
> **1. Most popular:** To check a password **between 6 to 15 characters** which contain at least one numeric digit and a special character
```js
string.validate.isPassword6to15("password1@") // password1@
string.validate.isPassword6to15("password1") // No special character
string.validate.isPassword6to15("password1") // false
```
<br/>
#### To check a password between 8 to 15 characters which contain at least one lowercase letter, one uppercase letter, one numeric digit, and one special character (Most Secure)
> **2. Most Secure:** To check a password **between 8 to 15 characters** which contain at least one lowercase letter, one uppercase letter, one numeric digit, and one special character
```js
string.validate.isPassword8to15("password1Aa_"); // password1Aa_
string.validate.isPassword8to15("password1") // false ( Not matched)
string.validate.isPassword8to15("password1") // false
```
<br/>
#### To check a password between 7 to 20 characters which contain only characters, numeric digits, underscore and first character must be a letter. No special character accepted here. (Simple password)
> **3. Simpler Password:** To check a password **between 6 to 20 characters** which contain at least one numeric digit, one uppercase and one lowercase letter
```js
string.validate.isPassword7to20("password1@_") // false (Because special character)
string.validate.isPassword7to20("password1") // password1
string.validate.isPassword6to20("password1Aa"); // password1Aa
string.validate.isPassword6to20("password1") // false
```
<br/>
#### To check a password between 6 to 20 characters which contain at least one numeric digit, one uppercase and one lowercase letter
> **4. Easy Password:** To check a password **between 7 to 20 characters** which contain only characters, numeric digits, underscore and first character must be a letter. No special character accepted here.
>
```js
string.validate.isPassword6to20("password1Aa"); // password1Aa
string.validate.isPassword6to20("password1") // false ( Not matched)
string.validate.isPassword7to20("password1") // password1
string.validate.isPassword7to20("password1@_") // false (No special character allowed)
```
<br/>
## Typescript compatitibility
### Typescript compatitibility
Thanks to @kewitz for typescript compatibility
Thanks to @JohannesDev for remove undercore function
Thanks to @JohannesDev for removeUnderscore function
## Contributing
### Contributing

@@ -144,4 +155,4 @@ Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

## License
### License
[MIT](https://github.com/fazlulkarimweb/string-sanitizer/blob/master/license)
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