Skip to content

Commit

Permalink
Revert "fix(backend): 名前を空白文字列だけにできる問題を修正 (misskey-dev#14119)"
Browse files Browse the repository at this point in the history
This reverts commit 9ef6c47.
  • Loading branch information
anatawa12 committed Aug 3, 2024
1 parent 6a52ef3 commit 4d33de9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 19 deletions.
9 changes: 1 addition & 8 deletions packages/backend/src/server/api/endpoints/i/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,14 +258,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
const profile = await this.userProfilesRepository.findOneByOrFail({ userId: user.id });
let policies: RolePolicies | null = null;

if (ps.name !== undefined) {
if (ps.name === null) {
updates.name = null;
} else {
const trimmedName = ps.name.trim();
updates.name = trimmedName === '' ? null : trimmedName;
}
}
if (ps.name !== undefined) updates.name = ps.name;
if (ps.description !== undefined) profileUpdates.description = ps.description;
if (ps.lang !== undefined) profileUpdates.lang = ps.lang;
if (ps.location !== undefined) profileUpdates.location = ps.location;
Expand Down
13 changes: 2 additions & 11 deletions packages/backend/test/e2e/endpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,21 +117,12 @@ describe('Endpoints', () => {
assert.strictEqual(res.body.birthday, myBirthday);
});

test('名前を空白のみにした場合nullになる', async () => {
test('名前を空白にできる', async () => {
const res = await api('i/update', {
name: ' ',
}, alice);
assert.strictEqual(res.status, 200);
assert.strictEqual(res.body.name, null);
});

test('名前の前後に空白(ホワイトスペース)を入れてもトリムされる', async () => {
const res = await api('i/update', {
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar#white_space
name: ' あ い う \u0009\u000b\u000c\u0020\u00a0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\ufeff',
}, alice);
assert.strictEqual(res.status, 200);
assert.strictEqual(res.body.name, 'あ い う');
assert.strictEqual(res.body.name, ' ');
});

test('誕生日の設定を削除できる', async () => {
Expand Down

0 comments on commit 4d33de9

Please sign in to comment.