feat(images): default frontend assets to image service

This commit is contained in:
2026-08-08 09:30:58 +00:00
parent bda76b7888
commit 4374c490ac
28 changed files with 228 additions and 61 deletions
+12 -9
View File
@@ -9,13 +9,13 @@ import {
} from '../src/utils/generalIcon.ts';
void describe('generalIcon', () => {
void it('routes user icons through the gateway and encodes the complete filename', () => {
void it('preserves server-issued user icon path segments while encoding traversal segments', () => {
assert.equal(
resolveGeneralIconUrl(
{ picture: '계정 icon/../1.jpg', imageServer: 1 },
{ userIconBaseUrl: '/gateway/api/user-icons/' }
),
'/gateway/api/user-icons/%EA%B3%84%EC%A0%95%20icon%2F..%2F1.jpg'
'/gateway/api/user-icons/%EA%B3%84%EC%A0%95%20icon/%2E%2E/1.jpg'
);
});
@@ -30,31 +30,34 @@ void describe('generalIcon', () => {
);
assert.equal(
resolveGeneralIconUrl({ picture: '장수/관우 1.png', imageServer: 0 }),
'/image/icons/%EC%9E%A5%EC%88%98/%EA%B4%80%EC%9A%B0%201.png'
'https://sam-image.hided.net/icons/%EC%9E%A5%EC%88%98/%EA%B4%80%EC%9A%B0%201.png'
);
assert.equal(
resolveGeneralIconUrl({ picture: '../secret.png', imageServer: 0 }),
'/image/icons/%2E%2E/secret.png'
'https://sam-image.hided.net/icons/%2E%2E/secret.png'
);
});
void it('uses a deterministic default and safe layered fallback for CSS backgrounds', () => {
assert.equal(resolveGeneralIconUrl({ picture: null, imageServer: 0 }), '/image/icons/default.jpg');
assert.equal(
resolveGeneralIconUrl({ picture: null, imageServer: 0 }),
'https://sam-image.hided.net/icons/default.jpg'
);
assert.equal(
resolveGeneralIconBackgroundImage(
{ picture: 'custom.jpg', imageServer: 1 },
{ userIconBaseUrl: '/gateway/api/user-icons' }
),
'url("/gateway/api/user-icons/custom.jpg"), url("/image/icons/default.jpg")'
'url("/gateway/api/user-icons/custom.jpg"), url("https://sam-image.hided.net/icons/default.jpg")'
);
});
void it('translates legacy message d_pic references without changing absolute or external icons', () => {
assert.equal(
resolveMessageGeneralIconUrl('d_pic/user name.jpg', '/gateway/api/user-icons/'),
'/gateway/api/user-icons/user%20name.jpg'
resolveMessageGeneralIconUrl('d_pic/users/core2026/user name.jpg', '/gateway/api/user-icons/'),
'/gateway/api/user-icons/users/core2026/user%20name.jpg'
);
assert.equal(resolveMessageGeneralIconUrl('/image/icons/22.jpg'), '/image/icons/22.jpg');
assert.equal(resolveMessageGeneralIconUrl('/image/icons/22.jpg'), 'https://sam-image.hided.net/icons/22.jpg');
assert.equal(resolveMessageGeneralIconUrl('https://cdn.example/icon.jpg'), 'https://cdn.example/icon.jpg');
assert.equal(resolveMessageGeneralIconUrl(''), DEFAULT_GENERAL_ICON_URL);
});