@meistrari/tela-build 1.50.1 → 1.50.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { defineNuxtPlugin, useRuntimeConfig } from 'nuxt/app'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* tela-build's avatar sanitizer (`sanitizeAvatarImageUrl`) reads its host
|
|
5
|
+
* allowlist from the legacy `window.__NUXT__.config.public` global, which Nuxt 4
|
|
6
|
+
* no longer populates. Without it the sanitizer only ever sees its hardcoded
|
|
7
|
+
* hosts (Google/MS/GitHub/Gravatar), so avatars served from `avatarAllowedOrigins`
|
|
8
|
+
* (e.g. vault asset hosts) fall back to initials.
|
|
9
|
+
*
|
|
10
|
+
* This is a fallback/polyfill, not a replacement: when the global is already
|
|
11
|
+
* populated (Nuxt 3) we leave it untouched, otherwise we mirror the public
|
|
12
|
+
* runtime config onto it so the sanitizer can resolve the configured hosts.
|
|
13
|
+
*/
|
|
14
|
+
export default defineNuxtPlugin(() => {
|
|
15
|
+
const globalWithNuxt = window as typeof window & {
|
|
16
|
+
__NUXT__?: { config?: { public?: Record<string, unknown> } }
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if (globalWithNuxt.__NUXT__?.config?.public)
|
|
20
|
+
return
|
|
21
|
+
|
|
22
|
+
const { public: publicConfig } = useRuntimeConfig()
|
|
23
|
+
|
|
24
|
+
globalWithNuxt.__NUXT__ ??= {}
|
|
25
|
+
globalWithNuxt.__NUXT__.config ??= {}
|
|
26
|
+
globalWithNuxt.__NUXT__.config.public = publicConfig
|
|
27
|
+
})
|