diff --git a/src/lib/config/Config.ts b/src/lib/config/Config.ts index 03d41d8e..bdb25ec1 100644 --- a/src/lib/config/Config.ts +++ b/src/lib/config/Config.ts @@ -57,6 +57,7 @@ export interface ConfigUploader { format_date: string; default_expiration: string; assume_mimetypes: boolean; + random_words_separator: string; } export interface ConfigUrls { diff --git a/src/lib/config/readConfig.ts b/src/lib/config/readConfig.ts index 0f087048..265affb1 100644 --- a/src/lib/config/readConfig.ts +++ b/src/lib/config/readConfig.ts @@ -98,6 +98,7 @@ export default function readConfig() { map('UPLOADER_FORMAT_DATE', 'string', 'uploader.format_date'), map('UPLOADER_DEFAULT_EXPIRATION', 'string', 'uploader.default_expiration'), map('UPLOADER_ASSUME_MIMETYPES', 'boolean', 'uploader.assume_mimetypes'), + map('UPLOADER_RANDOM_WORDS_SEPARATOR', 'string', 'uploader.random_words_separator'), map('URLS_ROUTE', 'string', 'urls.route'), map('URLS_LENGTH', 'number', 'urls.length'), diff --git a/src/lib/config/validateConfig.ts b/src/lib/config/validateConfig.ts index 2938e4d7..2a07c5d4 100644 --- a/src/lib/config/validateConfig.ts +++ b/src/lib/config/validateConfig.ts @@ -97,6 +97,7 @@ const validator = s.object({ format_date: s.string.default('YYYY-MM-DD_HH:mm:ss'), default_expiration: s.string.optional.default(null), assume_mimetypes: s.boolean.default(false), + random_words_separator: s.string.default('-'), }) .default({ default_format: 'RANDOM', diff --git a/src/lib/format/gfycat.ts b/src/lib/format/gfycat.ts index 114b8b86..f483b68d 100644 --- a/src/lib/format/gfycat.ts +++ b/src/lib/format/gfycat.ts @@ -1,4 +1,5 @@ import { readFile } from 'fs/promises'; +import config from 'lib/config'; export type GfyCatWords = { adjectives: string[]; @@ -22,5 +23,7 @@ function randomWord(words: string[]) { export default async function gfycat() { const words = await importWords(); - return `${randomWord(words.adjectives)} ${randomWord(words.adjectives)} ${randomWord(words.animals)}`; + return `${randomWord(words.adjectives)}${config.uploader.random_words_separator}${randomWord( + words.adjectives + )}${config.uploader.random_words_separator}${randomWord(words.animals)}`; }