MCPcopy Create free account
hub / github.com/facebook/Rapid / getAssetURL

Method getAssetURL

modules/core/AssetSystem.js:232–245  ·  view source on GitHub ↗

* getAssetURL * Returns the URL for the given asset key. * @param {string} key - identifier for the asset, should be found in the asset map. * @return {string} URL of the asset * @throws Will throw if the asset key is not found, or the current origin is invalid

(key)

Source from the content-addressed store, hash-verified

230 * @throws Will throw if the asset key is not found, or the current origin is invalid
231 */
232 getAssetURL(key) {
233 if (/^http(s)?:\/\//i.test(key)) return key; // already a url
234
235 const sources = this.sources[this.origin];
236 if (!sources) {
237 throw new Error(`Unknown origin "${this.origin}"`);
238 }
239 const val = sources[key];
240 if (!val) {
241 throw new Error(`Unknown asset key "${key}"`);
242 }
243
244 return this.getFileURL(val);
245 }
246
247
248 /**

Callers 5

loadAssetAsyncMethod · 0.95
_loadMapLibreAsyncMethod · 0.80
_loadAssetsAsyncMethod · 0.80
_loadAssetsAsyncMethod · 0.80

Calls 1

getFileURLMethod · 0.95

Tested by

no test coverage detected