@descope/web-components-ui 1.0.368 → 1.0.369

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.esm.js CHANGED
@@ -1401,7 +1401,9 @@ const getFileExtension = (path) => {
1401
1401
  return match ? match[1] : null;
1402
1402
  };
1403
1403
 
1404
- const isSvg = (src) => getFileExtension(src) === 'svg' || src.indexOf('image/svg+xml') > -1;
1404
+ const base64Prefix = 'data:image/svg+xml;base64,';
1405
+
1406
+ const isBase64Svg = (src) => src.startsWith(base64Prefix);
1405
1407
 
1406
1408
  const createImgEle = (src) => {
1407
1409
  const ele = document.createElement('img');
@@ -1418,12 +1420,17 @@ const createSvgEle = (text) => {
1418
1420
  const createIcon = async (src) => {
1419
1421
  try {
1420
1422
  let ele;
1421
-
1422
- if (isSvg(src)) {
1423
+ if (isBase64Svg(src)) {
1424
+ // handle base64 source
1425
+ const svgXml = atob(src.slice(base64Prefix.length));
1426
+ ele = createSvgEle(svgXml);
1427
+ } else if (getFileExtension(src) === 'svg') {
1428
+ // handle urls
1423
1429
  const fetchedSrc = await fetch(src);
1424
1430
  const text = await fetchedSrc.text();
1425
1431
  ele = createSvgEle(text);
1426
1432
  } else {
1433
+ // handle binary
1427
1434
  ele = createImgEle(src);
1428
1435
  }
1429
1436