ssovee-os-web-ui 0.1.17 → 0.1.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -663,29 +663,33 @@ var ImageWithPlaceholder = ({
663
663
  onError,
664
664
  ...props
665
665
  }) => {
666
+ const resolveSrc = (s) => {
667
+ if (s && typeof s === "object" && "src" in s && typeof s.src === "string") {
668
+ return s.src;
669
+ }
670
+ return typeof s === "string" ? s : void 0;
671
+ };
666
672
  const isValidSrc = (s) => {
667
673
  if (!s) return false;
668
- if (typeof s === "object") return true;
669
- if (typeof s === "string") {
670
- const trimmed = s.trim();
671
- if (trimmed === "") return false;
672
- if (trimmed.startsWith("data:")) return true;
673
- if (trimmed.startsWith("/") || trimmed.startsWith("./") || trimmed.startsWith("../")) return true;
674
- try {
675
- new URL(trimmed);
676
- return true;
677
- } catch {
678
- return false;
679
- }
674
+ const trimmed = s.trim();
675
+ if (trimmed === "") return false;
676
+ if (trimmed.startsWith("data:")) return true;
677
+ if (trimmed.startsWith("/") || trimmed.startsWith("./") || trimmed.startsWith("../")) return true;
678
+ try {
679
+ new URL(trimmed);
680
+ return true;
681
+ } catch {
682
+ return false;
680
683
  }
681
- return true;
682
684
  };
683
- const initialSrc = isValidSrc(src) ? src : fallbackSrc;
685
+ const resolvedSrc = resolveSrc(src);
686
+ const initialSrc = isValidSrc(resolvedSrc) ? resolvedSrc : fallbackSrc;
684
687
  const [imgSrc, setImgSrc] = React20.useState(initialSrc);
685
- const [hasError, setHasError] = React20.useState(!isValidSrc(src));
688
+ const [hasError, setHasError] = React20.useState(!isValidSrc(resolvedSrc));
686
689
  React20.useEffect(() => {
687
- if (isValidSrc(src)) {
688
- setImgSrc(src);
690
+ const nextResolvedSrc = resolveSrc(src);
691
+ if (isValidSrc(nextResolvedSrc)) {
692
+ setImgSrc(nextResolvedSrc);
689
693
  setHasError(false);
690
694
  } else {
691
695
  setImgSrc(fallbackSrc);