forked from cadence/out-of-your-element
Compare commits
No commits in common. "5a0e7f6a6666b6f3c3f620c9560c83eb362d0679" and "e146faced163a1b99fb0e4ac83cc9dbe4eecb5f8" have entirely different histories.
5a0e7f6a66
...
e146faced1
3 changed files with 5 additions and 14 deletions
|
|
@ -20,10 +20,10 @@ const SPECIAL_USER_MAPPINGS = new Map([
|
||||||
function downcaseUsername(user) {
|
function downcaseUsername(user) {
|
||||||
// First, try to convert the username to the set of allowed characters
|
// First, try to convert the username to the set of allowed characters
|
||||||
let downcased = user.username.toLowerCase()
|
let downcased = user.username.toLowerCase()
|
||||||
// spaces and slashes to underscores...
|
// spaces to underscores...
|
||||||
.replace(/[ /]/g, "_")
|
.replace(/ /g, "_")
|
||||||
// remove disallowed characters...
|
// remove disallowed characters...
|
||||||
.replace(/[^a-z0-9._=-]*/g, "")
|
.replace(/[^a-z0-9._=/-]*/g, "")
|
||||||
// remove leading and trailing dashes and underscores...
|
// remove leading and trailing dashes and underscores...
|
||||||
.replace(/(?:^[_-]*|[_-]*$)/g, "")
|
.replace(/(?:^[_-]*|[_-]*$)/g, "")
|
||||||
// If requested, also make the Discord user ID part of the username
|
// If requested, also make the Discord user ID part of the username
|
||||||
|
|
|
||||||
|
|
@ -21,12 +21,8 @@ test("user2name: works on single emoji at the end", t => {
|
||||||
t.equal(userToSimName({username: "Melody 🎵", discriminator: "2192"}), "melody")
|
t.equal(userToSimName({username: "Melody 🎵", discriminator: "2192"}), "melody")
|
||||||
})
|
})
|
||||||
|
|
||||||
test("user2name: works on really weird name", t => {
|
test("user2name: works on crazy name", t => {
|
||||||
t.equal(userToSimName({username: "*** D3 &W (89) _7//-", discriminator: "0001"}), "d3_w_89__7")
|
t.equal(userToSimName({username: "*** D3 &W (89) _7//-", discriminator: "0001"}), "d3_w_89__7//")
|
||||||
})
|
|
||||||
|
|
||||||
test("user2name: treats slashes", t => {
|
|
||||||
t.equal(userToSimName({username: "Evil Lillith (she/her)", discriminator: "5892"}), "evil_lillith_she_her")
|
|
||||||
})
|
})
|
||||||
|
|
||||||
test("user2name: adds discriminator if name is unavailable (old tag format)", t => {
|
test("user2name: adds discriminator if name is unavailable (old tag format)", t => {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +0,0 @@
|
||||||
BEGIN TRANSACTION;
|
|
||||||
|
|
||||||
DELETE FROM sim WHERE sim_name like '%/%';
|
|
||||||
|
|
||||||
COMMIT;
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue