(dirHref)
| 2884 | } |
| 2885 | |
| 2886 | async function fetchDirListingPngFiles(dirHref) { |
| 2887 | try { |
| 2888 | const res = await fetch(`${dirHref}?v=${Date.now()}`, { cache: "no-store" }); |
| 2889 | if (!res.ok) return []; |
| 2890 | const text = await res.text(); |
| 2891 | // Parse Apache/python http.server listings (simple HTML with <a href="...">) |
| 2892 | const doc = new DOMParser().parseFromString(text, "text/html"); |
| 2893 | const anchors = Array.from(doc.querySelectorAll("a[href]")); |
| 2894 | const files = anchors |
| 2895 | .map((a) => a.getAttribute("href") || "") |
| 2896 | .filter((href) => href && !href.startsWith("?") && !href.startsWith("#")) |
| 2897 | .map((href) => href.replace(/\\/g, "/")) |
| 2898 | .filter((href) => href.toLowerCase().endsWith(".png")) |
| 2899 | // decode URL-encoded names from listing |
| 2900 | .map((href) => { |
| 2901 | try { return decodeURIComponent(href); } catch { return href; } |
| 2902 | }) |
| 2903 | // drop any path segments, keep filename only |
| 2904 | .map((href) => (href.split("/").pop() || href).trim()) |
| 2905 | .filter(Boolean); |
| 2906 | // Deduplicate |
| 2907 | return Array.from(new Set(files)); |
| 2908 | } catch { |
| 2909 | return []; |
| 2910 | } |
| 2911 | } |
| 2912 | |
| 2913 | async function tryLoadIconsFromDirectoryListing() { |
| 2914 | // Try known size folders; if they don't exist or listing is disabled, we'll fall back. |
no outgoing calls
no test coverage detected