Files
SnowLuma/.pnpm-store/v11/files/ea/bc8c70d6fb2ca112ca30bad6afa910e4e652fa70f17ffedf231256797b1de67fb456a4e4900f043f6724a2deea67dc511619e2fc95aa206d961b6a10937886
T
TanTan 2a69b23b47
Dev Build / cleanup (push) Waiting to run
Dev Build / typecheck (push) Waiting to run
docs: 仓库链接指向本镜像仓库
2026-11-13 09:27:07 +08:00

73 lines
2.4 KiB
Plaintext

'use strict';
var _const = require('../../data/const.cjs');
const getDictionaryWarningPassword = (options, match, isSoleMatch) => {
let warning = null;
if (isSoleMatch && !match.l33t && !match.reversed) {
if (match.rank <= 10) {
warning = options.translations.warnings.topTen;
} else if (match.rank <= 100) {
warning = options.translations.warnings.topHundred;
} else {
warning = options.translations.warnings.common;
}
} else if (match.guessesLog10 <= 4) {
warning = options.translations.warnings.similarToCommon;
}
return warning;
};
const getDictionaryWarningWikipedia = (options, match, isSoleMatch) => {
let warning = null;
if (isSoleMatch) {
warning = options.translations.warnings.wordByItself;
}
return warning;
};
const getDictionaryWarningNames = (options, match, isSoleMatch) => {
if (isSoleMatch) {
return options.translations.warnings.namesByThemselves;
}
return options.translations.warnings.commonNames;
};
const getDictionaryWarning = (options, match, isSoleMatch) => {
const dictName = match.dictionaryName;
const isAName = dictName.toLowerCase().includes('lastnames') || dictName.toLowerCase().includes('firstnames') || dictName.toLowerCase().includes('names');
if (dictName.includes('passwords')) {
return getDictionaryWarningPassword(options, match, isSoleMatch);
}
if (dictName.includes('wikipedia')) {
return getDictionaryWarningWikipedia(options, match, isSoleMatch);
}
if (isAName) {
return getDictionaryWarningNames(options, match, isSoleMatch);
}
if (dictName.includes('userInputs')) {
return options.translations.warnings.userInputs;
}
return null;
};
var dictionaryMatcher = (options, match, isSoleMatch) => {
const warning = getDictionaryWarning(options, match, isSoleMatch);
const suggestions = [];
const word = match.token;
if (word.match(_const.START_UPPER)) {
suggestions.push(options.translations.suggestions.capitalization);
} else if (word.match(_const.ALL_UPPER_INVERTED) && word.toLowerCase() !== word) {
suggestions.push(options.translations.suggestions.allUppercase);
}
if (match.reversed && match.token.length >= 4) {
suggestions.push(options.translations.suggestions.reverseWords);
}
if (match.l33t) {
suggestions.push(options.translations.suggestions.l33t);
}
return {
warning,
suggestions
};
};
module.exports = dictionaryMatcher;
//# sourceMappingURL=feedback.cjs.map