Trust embedded Zillow photo sets without visible count
This commit is contained in:
@@ -58,11 +58,29 @@ export function extractZillowStructuredPhotoCandidatesFromNextDataScript(scriptT
|
||||
return out;
|
||||
}
|
||||
|
||||
export function shouldUseStructuredZillowPhotos(candidates, expectedPhotoCount) {
|
||||
const DEFAULT_MINIMUM_TRUSTED_STRUCTURED_PHOTO_COUNT = 12;
|
||||
|
||||
export function shouldUseStructuredZillowPhotos(candidates, options = {}) {
|
||||
const count = Array.isArray(candidates) ? candidates.length : 0;
|
||||
if (!Number.isFinite(expectedPhotoCount) || expectedPhotoCount <= 0) {
|
||||
return false;
|
||||
const normalizedOptions =
|
||||
typeof options === "number"
|
||||
? { expectedPhotoCount: options }
|
||||
: options && typeof options === "object"
|
||||
? options
|
||||
: {};
|
||||
const expectedPhotoCount = Number(normalizedOptions.expectedPhotoCount || 0);
|
||||
const fallbackPhotoCount = Number(normalizedOptions.fallbackPhotoCount || 0);
|
||||
const minimumTrustCount = Number(
|
||||
normalizedOptions.minimumTrustCount || DEFAULT_MINIMUM_TRUSTED_STRUCTURED_PHOTO_COUNT
|
||||
);
|
||||
|
||||
if (Number.isFinite(expectedPhotoCount) && expectedPhotoCount > 0) {
|
||||
return count >= expectedPhotoCount;
|
||||
}
|
||||
|
||||
return count >= expectedPhotoCount;
|
||||
if (Number.isFinite(fallbackPhotoCount) && fallbackPhotoCount > 0) {
|
||||
return count >= fallbackPhotoCount;
|
||||
}
|
||||
|
||||
return count >= minimumTrustCount;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user