mirror of
https://github.com/duckietm/Nitro-V3.git
synced 2026-06-20 15:36:18 +00:00
🆙 Small update news images
This commit is contained in:
@@ -9,8 +9,12 @@ export const resolveNewsImage = (raw: string | null | undefined): string =>
|
|||||||
const value = (raw ?? '').trim();
|
const value = (raw ?? '').trim();
|
||||||
if(!value) return '';
|
if(!value) return '';
|
||||||
if(/^https?:\/\//i.test(value)) return value;
|
if(/^https?:\/\//i.test(value)) return value;
|
||||||
if(value.startsWith('//')) return value;
|
if(value.startsWith('//')) return window.location.protocol + value;
|
||||||
if(value.startsWith('/') && !value.startsWith('//')) return value;
|
if(value.startsWith('/'))
|
||||||
|
{
|
||||||
|
try { return new URL(value, window.location.origin).href; }
|
||||||
|
catch { return window.location.origin + value; }
|
||||||
|
}
|
||||||
if(value.startsWith('data:'))
|
if(value.startsWith('data:'))
|
||||||
{
|
{
|
||||||
return /^data:image\/[a-z0-9.+-]+[,;]/i.test(value) ? value : '';
|
return /^data:image\/[a-z0-9.+-]+[,;]/i.test(value) ? value : '';
|
||||||
|
|||||||
Reference in New Issue
Block a user