* 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)
| 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 | /** |
no test coverage detected