Accept ampersands urls in cameras/lenses
This commit is contained in:
parent
ea1e232232
commit
27b0b4965a
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user