From 88ef90fb3802e384166f4b6e0fbf2fc1f4f9922c Mon Sep 17 00:00:00 2001 From: Sam Becker Date: Sat, 29 Mar 2025 12:06:12 -0500 Subject: [PATCH] Categorize pixels lenses without makes --- src/lens/index.ts | 12 +++++++----- src/platforms/google.ts | 5 +++-- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/lens/index.ts b/src/lens/index.ts index a49f892b..3242d424 100644 --- a/src/lens/index.ts +++ b/src/lens/index.ts @@ -1,8 +1,8 @@ import { Photo } from '@/photo'; import { parameterize } from '@/utility/string'; -import { formatAppleLensText, isLensMakeApple } from '../platforms/apple'; +import { formatAppleLensText, isLensApple } from '../platforms/apple'; import { MISSING_FIELD } from '@/app/paths'; -import { formatGoogleLensText, isLensMakeGoogle } from '../platforms/google'; +import { formatGoogleLensText, isLensGoogle } from '../platforms/google'; const LENS_PLACEHOLDER: Lens = { make: 'Lens', model: 'Model' }; @@ -88,13 +88,15 @@ export const lensFromPhoto = ( : fallback ?? LENS_PLACEHOLDER; export const formatLensText = ( - { make, model: modelRaw }: Lens, + lens: Lens, length: 'long' | // Unmodified make and model 'medium' | // Make and model, with modifiers removed 'short' // Model only = 'medium', ) => { + const { make, model: modelRaw } = lens; + // Capture simple make without modifiers like 'Corporation' or 'Company' const makeSimple = make?.match(/^(\S+)/)?.[1]; const doesModelStartWithMake = ( @@ -102,9 +104,9 @@ export const formatLensText = ( modelRaw.toLocaleLowerCase().startsWith(makeSimple.toLocaleLowerCase()) ); - const model = isLensMakeApple(make) + const model = isLensApple(lens) ? formatAppleLensText(modelRaw, length === 'medium') - : isLensMakeGoogle(make) + : isLensGoogle(lens) ? formatGoogleLensText(modelRaw, length === 'medium') : modelRaw; diff --git a/src/platforms/google.ts b/src/platforms/google.ts index e4b0fa85..80d43c63 100644 --- a/src/platforms/google.ts +++ b/src/platforms/google.ts @@ -13,8 +13,9 @@ export const isCameraGoogle = ({ make }: Camera) => export const isLensMakeGoogle = (make?: string) => make?.toLocaleLowerCase() === MAKE_GOOGLE; -export const isLensGoogle = ({ make }: Lens) => - isLensMakeGoogle(make); +export const isLensGoogle = ({ make, model }: Lens) => + isLensMakeGoogle(make) || + /^Pixel [0-9a-z]+/i.test(model); export const formatGoogleLensText = ( model: string,