@mohasinac/appkit 4.42.7 → 4.42.8
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/dist/utils/media-url.js +17 -0
- package/package.json +1 -1
package/dist/utils/media-url.js
CHANGED
|
@@ -129,6 +129,23 @@ const OWN_STORAGE_BUCKET = process.env.NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET ?? ""
|
|
|
129
129
|
export function resolveMediaUrl(url, opts) {
|
|
130
130
|
if (!url)
|
|
131
131
|
return undefined;
|
|
132
|
+
/*
|
|
133
|
+
* 🛑 Same type-guard as `isStoredMediaRef`, and for the same reason: this is a
|
|
134
|
+
* RENDER-path helper called from `MediaImage`, every avatar, every logo and
|
|
135
|
+
* every card, with whatever the document happens to hold. `!url` catches
|
|
136
|
+
* null/undefined/""; an object or array is truthy and falls straight through
|
|
137
|
+
* to `.startsWith`, throwing `TypeError: e.startsWith is not a function` and
|
|
138
|
+
* taking out the whole subtree it was rendering.
|
|
139
|
+
*
|
|
140
|
+
* Returning undefined is the documented behaviour for a falsy input and is the
|
|
141
|
+
* right answer here too — the caller renders its placeholder instead of
|
|
142
|
+
* crashing. The warn names the shape so the real caller stays findable.
|
|
143
|
+
*/
|
|
144
|
+
if (typeof url !== "string") {
|
|
145
|
+
// eslint-disable-next-line no-console -- render path; a throw here kills the subtree
|
|
146
|
+
console.warn("[resolveMediaUrl] expected a string, received", Object.prototype.toString.call(url));
|
|
147
|
+
return undefined;
|
|
148
|
+
}
|
|
132
149
|
if (url.startsWith(PROXY_PREFIX))
|
|
133
150
|
return url;
|
|
134
151
|
// A blob:/data: URI is only ever valid in the tab that created it (e.g. a
|