Skip to content

Commit

Permalink
don't read spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
sarisia committed Jan 20, 2024
1 parent 5673252 commit 5f9aeb9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/zundacord/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ export function getReadableString(str: string): string {
// FIXME: make this configurable per user
ret = toKana(ret)

// seems voicevox reads spaces
ret = ret.trim()
// seems voicevox reads spaces, so lets remove them
ret = ret.replace(/[\s ]+/g, '');

return ret
}
15 changes: 8 additions & 7 deletions tests/zundacord/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,23 @@ test.each([
["", ""],
["はろー 🤔", "はろー"],
["はろー <:hello:1234567890>", "はろー"],
["はろー あにめーしょん <a:hello:1234567890>", "はろー あにめーしょん"],
["はろー あにめーしょん <a:hello:1234567890>", "はろーあにめーしょん"],
["😎😍😒 はろー <:hello:1234567890> <:hello:1234567890> <:hello:1234567890>", "はろー"],
["<:hello:1234567890> 😎 <:hello:1234567890> はろー 🤔 <:hello:1234567890> 🤔", "はろー"],
["12345はろー54321", "12345はろー54321"],
["プロロのキレ良し?", "プロロのキレ良し?"],
["プロロのキレ良し!?", "プロロのキレ良し!?"], // this is converted by wanakana's `toKana`
["びじっと https://sarisia.cc", "びじっと リンク"],
["びじっと http://sarisia.cc", "びじっと リンク"],
["びじっと http://sarisia.cc http://sarisia.cc", "びじっと リンク リンク"],
["びじっと http://sarisia.cc\nhttp://sarisia.cc", "びじっと リンク リンク"],
["かなり\r\nべりー\nふぁすと", "かなり べりー ふぁすと"],
["びじっと https://sarisia.cc", "びじっとリンク"],
["びじっと http://sarisia.cc", "びじっとリンク"],
["びじっと http://sarisia.cc http://sarisia.cc", "びじっとリンクリンク"],
["びじっと http://sarisia.cc\nhttp://sarisia.cc", "びじっとリンクリンク"],
["かなり\r\nべりー\nふぁすと", "かなりべりーふぁすと"],
["すぺーす すぺーす すぺーす", "すぺーすすぺーすすぺーす"],
// test `~` -> `ー`
["啜る~~~", "啜るーーー"],
// wanakana tests
["wanakana", "わなかな"],
["wanakana はろー 😎😍😒 <a:hello:1234567890>", "わなかな はろー"],
["wanakana はろー 😎😍😒 <a:hello:1234567890>", "わなかなはろー"],
])("getReadableString(%s)", (str, expected) => {
expect(getReadableString(str)).toBe(expected)
})

0 comments on commit 5f9aeb9

Please sign in to comment.