Support pluses in lens makes
This commit is contained in:
parent
b3dba5f676
commit
f8c0a46f2f
@ -7,13 +7,17 @@ import { Lens } from '@/lens';
|
||||
export const GENERATE_STATIC_PARAMS_LIMIT = 1000;
|
||||
export const PHOTO_DEFAULT_LIMIT = 100;
|
||||
|
||||
// Trim whitespace
|
||||
// Make lowercase
|
||||
// Remove commas, slashes
|
||||
// Replace spaces with dashes
|
||||
const DB_PARAMETERIZE_REPLACEMENTS = [
|
||||
[',', ''],
|
||||
['/', ''],
|
||||
['+', '-'],
|
||||
[' ', '-'],
|
||||
];
|
||||
|
||||
const parameterizeForDb = (field: string) =>
|
||||
// eslint-disable-next-line max-len
|
||||
`REPLACE(REPLACE(REPLACE(LOWER(TRIM(${field})), ',', ''), '/', ''), ' ', '-')`;
|
||||
DB_PARAMETERIZE_REPLACEMENTS.reduce((acc, [from, to]) =>
|
||||
`REPLACE(${acc}, '${from}', '${to}')`
|
||||
, `LOWER(TRIM(${field}))`);
|
||||
|
||||
export type GetPhotosOptions = {
|
||||
sortBy?: 'createdAt' | 'createdAtAsc' | 'takenAt' | 'priority'
|
||||
|
||||
@ -22,11 +22,11 @@ export const parameterize = (
|
||||
) =>
|
||||
string
|
||||
.trim()
|
||||
// Replaces spaces, underscores, slashes,and dashes with dashes
|
||||
.replaceAll(/[\s_–—]/gi, '-')
|
||||
// Removes punctuation
|
||||
.replaceAll(/['"!@#$%^&*()_+=[\]{};:/?,<>\\/|`~]/gi, '')
|
||||
// Removes all non-alphanumeric characters
|
||||
// Replace spaces, underscores, slashes, pluses, dashes with dashes
|
||||
.replaceAll(/[\s_–—+]/gi, '-')
|
||||
// Remove punctuation
|
||||
.replaceAll(/['"!@#$%^&*()=[\]{};:/?,<>\\/|`~]/gi, '')
|
||||
// Removes non-alphanumeric characters, if configured
|
||||
.replaceAll(
|
||||
shouldRemoveNonAlphanumeric
|
||||
? /([^a-z0-9-])/gi
|
||||
|
||||
Loading…
Reference in New Issue
Block a user