Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export analyzePassword Function #2468

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ Sanitizer | Description
**trim(input [, chars])** | trim characters (whitespace by default) from both sides of the input.
**unescape(input)** | replace HTML encoded entities with `<`, `>`, `&`, `'`, `"`, `` ` ``, `\` and `/`.
**whitelist(input, chars)** | remove characters that do not appear in the whitelist. The characters are used in a RegExp and so you will need to escape some chars, e.g. `whitelist(input, '\\[\\]')`.
**analyzePassword(str)** | Analyzes and returns details about the given string's composition as a password. Returns an object containing the password's length, count of unique characters, and the number of uppercase letters, lowercase letters, numbers, and symbols.

### XSS Sanitization

Expand Down
3 changes: 2 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ import normalizeEmail from './lib/normalizeEmail';

import isSlug from './lib/isSlug';
import isLicensePlate from './lib/isLicensePlate';
import isStrongPassword from './lib/isStrongPassword';
import isStrongPassword, { analyzePassword } from './lib/isStrongPassword';

import isVAT from './lib/isVAT';

Expand Down Expand Up @@ -237,6 +237,7 @@ const validator = {
toString,
isSlug,
isStrongPassword,
analyzePassword,
isTaxID,
isDate,
isTime,
Expand Down
2 changes: 1 addition & 1 deletion src/lib/isStrongPassword.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function countChars(str) {
}

/* Return information about a password */
function analyzePassword(password) {
export function analyzePassword(password) {
let charMap = countChars(password);
let analysis = {
length: password.length,
Expand Down
Loading