Accept ampersands urls in cameras/lenses

This commit is contained in:
Sam Becker 2025-07-16 23:36:14 -05:00
parent ea1e232232
commit 27b0b4965a
2 changed files with 11 additions and 12 deletions

View File

@ -7,18 +7,17 @@ import { APP_DEFAULT_SORT_BY, SortBy } from '../sort';
export const GENERATE_STATIC_PARAMS_LIMIT = 1000;
export const PHOTO_DEFAULT_LIMIT = 100;
const DB_PARAMETERIZE_REPLACEMENTS = [
[',', ''],
['/', ''],
['+', '-'],
['|', '-'],
[' ', '-'],
];
const CHARACTERS_TO_REMOVE = [',', '/'];
const CHARACTERS_TO_REPLACE = ['+', '&', '|', ' '];
const parameterizeForDb = (field: string) =>
DB_PARAMETERIZE_REPLACEMENTS.reduce((acc, [from, to]) =>
`REPLACE(${acc}, '${from}', '${to}')`
, `LOWER(TRIM(${field}))`);
`REGEXP_REPLACE(
REGEXP_REPLACE(
LOWER(TRIM(${field})),
'[${CHARACTERS_TO_REMOVE.join('')}]', '', 'g'
),
'[${CHARACTERS_TO_REPLACE.join('')}]', '-', 'g'
)`;
export type PhotoQueryOptions = {
sortBy?: SortBy

View File

@ -23,9 +23,9 @@ export const parameterize = (
string
.trim()
// Replace spaces, underscores, slashes, pluses, pipes, dashes with dashes
.replaceAll(/[\s_—+|]/gi, '-')
.replaceAll(/[\s_—+&|]/gi, '-')
// Remove punctuation
.replaceAll(/['"!@#$%^&*()=[\]{};:/?,<>\\/`~]/gi, '')
.replaceAll(/['"!@#$%^*()=[\]{};:/?,<>\\/`~]/gi, '')
// Removes non-alphanumeric characters, if configured
.replaceAll(
shouldRemoveNonAlphanumeric