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