@teamhive/lottie-player
Version:
Lottie animation web component.
17 lines (16 loc) • 395 B
JavaScript
/**
* Parse a resource into a JSON object or a URL string
*/
export function parseSrc(src) {
if (typeof src === 'object') {
return src;
}
try {
return JSON.parse(src);
}
catch (e) {
// Try construct an absolute URL from the src URL
const srcUrl = new URL(src, window.location.href);
return srcUrl.toString();
}
}