/**
 * 传入inspectionData, 找出所有的照片url
 * @param {*} obj
 * @returns
 */
export function findPhotosUrls(obj) {
  let urls = [];

  function recurse(current) {
    if (Array.isArray(current)) {
      current.forEach(recurse);
    } else if (current && typeof current === "object") {
      Object.keys(current).forEach((key) => {
        if (key === "photos" && Array.isArray(current[key])) {
          current[key].forEach((url) => {
            if (typeof url === "string") {
              urls.push(url.trim());
            }
          });
        } else {
          recurse(current[key]);
        }
      });
    }
  }

  recurse(obj);
  return urls;
}
