* feat: wip upload module * feat: local storage and serve local images * feat: protect against injections * feat: server local and s3 files * fix: use storage location when serving local files * feat: cross field env validation
22 lines
454 B
TypeScript
22 lines
454 B
TypeScript
const cropRegex = /([w|h])([0-9]+)/;
|
|
|
|
export type ShortCropSize = `${'w' | 'h'}${number}` | 'original';
|
|
|
|
export interface CropSize {
|
|
type: 'width' | 'height';
|
|
value: number;
|
|
}
|
|
|
|
export const getCropSize = (value: ShortCropSize): CropSize | null => {
|
|
const match = value.match(cropRegex);
|
|
|
|
if (value === 'original' || match === null) {
|
|
return null;
|
|
}
|
|
|
|
return {
|
|
type: match[1] === 'w' ? 'width' : 'height',
|
|
value: +match[2],
|
|
};
|
|
};
|