Fix the username formatter returning invalid formatName
'?' is not accepted character in OpenAI api as a valid name I also switched the order of the replace steps, so there will be less _- in the final username
This commit is contained in:
parent
276d70efee
commit
d5cb03502f
1 changed files with 3 additions and 3 deletions
|
@ -40,12 +40,12 @@ function formatName(name: string): string {
|
||||||
return FoldToAscii.foldReplacing(name)
|
return FoldToAscii.foldReplacing(name)
|
||||||
// White spaces are not allowed
|
// White spaces are not allowed
|
||||||
.replace(" ", "_")
|
.replace(" ", "_")
|
||||||
|
// replace characters that are not accepted by api with '_'
|
||||||
|
.replace(/[^a-zA-Z0-9_-]/g, "_")
|
||||||
// remove trailing '-_' characters
|
// remove trailing '-_' characters
|
||||||
.replace(/^[-_]+|[-_]+$/g, "")
|
.replace(/^[-_]+|[-_]+$/g, "")
|
||||||
// remove duplicated '-_' characters
|
// remove duplicated '-_' characters
|
||||||
.replace(/([-_])*/g, "")
|
.replace(/([-_])*/g, "$1");
|
||||||
// replace characters that are not accepted by api with '?'
|
|
||||||
.replace(/[^a-zA-Z0-9_-]/g, "?");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue