Accept full URLs for /api/v1/pleroma/emoji

The frontend assumes these URLs will be relative to the target instance,
which may not be the case due to object storage and such configurations.
This commit is contained in:
Kopper 2024-09-06 07:38:45 +03:00
parent 8da18fc209
commit c147c2aeb3

View file

@ -182,10 +182,13 @@ const instance = {
const result = await res.json()
const values = Array.isArray(result) ? Object.assign({}, ...result) : result
const emoji = Object.entries(values).map(([key, value]) => {
const imageUrl = value.image_url
let imageUrl = value.image_url
if (typeof imageUrl == 'string' && imageUrl.startsWith('/'))
imageUrl = state.server + imageUrl;
return {
displayText: key,
imageUrl: imageUrl ? state.server + imageUrl : value,
imageUrl: imageUrl ? imageUrl : value,
tags: imageUrl ? value.tags.sort((a, b) => a > b ? 1 : 0) : ['utf'],
replacement: `:${key}: `
}