mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-19 17:38:19 +08:00
core: fix saslprep error type
This commit is contained in:
1 parent
307b26ba4c
commit
c61c875bee
2 files changed
+15
-7
No files matched your search
@@ -43,10 +43,18 @@ export interface Types {
|
||||
Emoji: Type,
|
||||
}
|
||||
|
||||
const safeSaslprep = (v) => {
|
||||
try {
|
||||
return saslprep(v.toString().trim());
|
||||
} catch (e) {
|
||||
return '';
|
||||
}
|
||||
};
|
||||
|
||||
export const Types: Types = {
|
||||
Content: [(v) => v.toString().trim(), isContent],
|
||||
Name: [(v) => saslprep(v.toString().trim()), (v) => /^.{1,255}$/.test(saslprep(v.toString().trim()))],
|
||||
Username: [(v) => saslprep(v.toString().trim()), (v) => /^.{3,31}$/.test(saslprep(v.toString().trim()))],
|
||||
Name: [(v) => saslprep(v.toString().trim()), (v) => /^.{1,255}$/.test(safeSaslprep(v))],
|
||||
Username: [(v) => saslprep(v.toString().trim()), (v) => /^.{3,31}$/.test(safeSaslprep(v))],
|
||||
Title: [(v) => v.toString().trim(), isTitle],
|
||||
String: [(v) => v.toString(), null],
|
||||
Int: [(v) => parseInt(v, 10), (v) => isSafeInteger(parseInt(v, 10))],
|
||||
|
||||
Reference in new issue
Block a user