Dev Build / cleanup (push) Canceled after 0s
Dev Build / typecheck (push) Canceled after 0s
Dev Build / build (linux-arm64, ubuntu-24.04-arm, linux-arm64) (push) Canceled after 0s
Dev Build / build (linux-x64, ubuntu-latest, linux-x64) (push) Canceled after 0s
Dev Build / build (win-x64, windows-latest, win32-x64) (push) Canceled after 0s
Dev Build / dispatch-dev-docker (push) Canceled after 0s
39 lines
1.1 KiB
Plaintext
39 lines
1.1 KiB
Plaintext
import { REGEXEN } from '../../data/const.mjs';
|
|
import { sorted } from '../../utils/helper.mjs';
|
|
import { MatcherBaseClass } from '../../types.mjs';
|
|
|
|
/*
|
|
* -------------------------------------------------------------------------------
|
|
* regex matching ---------------------------------------------------------------
|
|
* -------------------------------------------------------------------------------
|
|
*/
|
|
class MatchRegex extends MatcherBaseClass {
|
|
match({
|
|
password
|
|
}) {
|
|
const matches = [];
|
|
Object.keys(REGEXEN).forEach(name => {
|
|
const regex = REGEXEN[name];
|
|
regex.lastIndex = 0; // keeps regexMatch stateless
|
|
let regexMatch;
|
|
while (regexMatch = regex.exec(password)) {
|
|
if (regexMatch) {
|
|
const token = regexMatch[0];
|
|
matches.push({
|
|
pattern: 'regex',
|
|
token,
|
|
i: regexMatch.index,
|
|
j: regexMatch.index + regexMatch[0].length - 1,
|
|
regexName: name,
|
|
regexMatch
|
|
});
|
|
}
|
|
}
|
|
});
|
|
return sorted(matches);
|
|
}
|
|
}
|
|
|
|
export { MatchRegex as default };
|
|
//# sourceMappingURL=matching.mjs.map
|