@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.
@@ -2622,7 +2622,9 @@ const getFileExtension = (path) => {
2622
2622
  return match ? match[1] : null;
2623
2623
  };
2624
2624
 
2625
- const isSvg = (src) => getFileExtension(src) === 'svg' || src.indexOf('image/svg+xml') > -1;
2625
+ const base64Prefix = 'data:image/svg+xml;base64,';
2626
+
2627
+ const isBase64Svg = (src) => src.startsWith(base64Prefix);
2626
2628
 
2627
2629
  const createImgEle = (src) => {
2628
2630
  const ele = document.createElement('img');
@@ -2639,12 +2641,17 @@ const createSvgEle = (text) => {
2639
2641
  const createIcon = async (src) => {
2640
2642
  try {
2641
2643
  let ele;
2642
-
2643
- if (isSvg(src)) {
2644
+ if (isBase64Svg(src)) {
2645
+ // handle base64 source
2646
+ const svgXml = atob(src.slice(base64Prefix.length));
2647
+ ele = createSvgEle(svgXml);
2648
+ } else if (getFileExtension(src) === 'svg') {
2649
+ // handle urls
2644
2650
  const fetchedSrc = await fetch(src);
2645
2651
  const text = await fetchedSrc.text();
2646
2652
  ele = createSvgEle(text);
2647
2653
  } else {
2654
+ // handle binary
2648
2655
  ele = createImgEle(src);
2649
2656
  }
2650
2657