Add Zillow and HAR photo extractors

This commit is contained in:
2026-03-27 17:35:46 -05:00
parent e7c56fe760
commit eeea0c8ef1
11 changed files with 873 additions and 8 deletions

View File

@@ -0,0 +1,66 @@
import test from "node:test";
import assert from "node:assert/strict";
import { normalizeImageCandidates } from "./real-estate-photo-common.js";
test("normalizeImageCandidates keeps distinct Zillow photo URLs and strips query strings", () => {
const result = normalizeImageCandidates(
[
{
url: "https://photos.zillowstatic.com/fp/abc123-p_e.jpg?set=1",
width: 1024,
height: 768,
},
{
url: "https://photos.zillowstatic.com/fp/abc123-p_e.jpg?set=2",
width: 1024,
height: 768,
},
{
url: "https://www.zillow.com/static/logo.png",
width: 120,
height: 40,
},
],
{
hostIncludes: ["photos.zillowstatic.com"],
minWidth: 240,
minHeight: 180,
}
);
assert.deepEqual(result.map((item) => item.url), [
"https://photos.zillowstatic.com/fp/abc123-p_e.jpg",
]);
});
test("normalizeImageCandidates filters tiny HAR page assets and keeps large photos", () => {
const result = normalizeImageCandidates(
[
{
url: "https://photos.har.com/123/main.jpg?size=large",
width: 1600,
height: 1200,
},
{
url: "https://cdn.har.com/icons/close.svg",
width: 24,
height: 24,
},
{
url: "data:image/png;base64,deadbeef",
width: 800,
height: 600,
},
],
{
hostExcludes: ["doubleclick", "gstatic"],
minWidth: 240,
minHeight: 180,
}
);
assert.deepEqual(result.map((item) => item.url), [
"https://photos.har.com/123/main.jpg",
]);
});