diff --git a/api/upload.ts b/api/upload.ts index 86551399..70a20398 100644 --- a/api/upload.ts +++ b/api/upload.ts @@ -41,14 +41,12 @@ const formidablePromise = async (req, opts) => { } const fileConsumer = (acc) => { - const writable = new Writable({ + return new Writable({ write: (chunk, _enc, next) => { acc.push(chunk) next() } }) - - return writable } async function handler(req, res) { diff --git a/src/components/Pages/profile/ProfileSettingsPage.tsx b/src/components/Pages/profile/ProfileSettingsPage.tsx index 79a5f10c..5a831aab 100644 --- a/src/components/Pages/profile/ProfileSettingsPage.tsx +++ b/src/components/Pages/profile/ProfileSettingsPage.tsx @@ -13,7 +13,7 @@ import validateUrl from '../../../utils/validateUrl' export const ProfileSettingsPage = (props: PageProps) => { const [addLinkForm, setAddLinkForm] = createSignal(false) const [incorrectUrl, setIncorrectUrl] = createSignal(false) - const { form, updateFormField, submit, error } = useProfileForm() + const { form, updateFormField, submit, slugError } = useProfileForm() const handleChangeSocial = (value) => { if (validateUrl(value)) { updateFormField('links', value) @@ -104,7 +104,7 @@ export const ProfileSettingsPage = (props: PageProps) => { value={form.slug} class="nolabel" /> -

{t(`error()`)}

+

{t(`${slugError()}`)}

diff --git a/src/context/profile.tsx b/src/context/profile.tsx index a90ba650..c8b8265c 100644 --- a/src/context/profile.tsx +++ b/src/context/profile.tsx @@ -10,13 +10,13 @@ const useProfileForm = () => { const currentSlug = createMemo(() => session()?.user?.slug) const { authorEntities } = useAuthorsStore({ authors: [] }) const currentAuthor = createMemo(() => authorEntities()[currentSlug()]) - const [error, setError] = createSignal() + const [slugError, setSlugError] = createSignal() const submit = async (profile: ProfileInput) => { try { const response = await apiClient.updateProfile(profile) if (response.error) { - setError(response.error) + setSlugError(response.error) return response.error } return response @@ -65,7 +65,7 @@ const useProfileForm = () => { }) } } - return { form, submit, updateFormField, error } + return { form, submit, updateFormField, slugError } } export { useProfileForm } diff --git a/src/utils/validateUrl.ts b/src/utils/validateUrl.ts index aaba15f6..1afc22ff 100644 --- a/src/utils/validateUrl.ts +++ b/src/utils/validateUrl.ts @@ -1,7 +1,5 @@ const validateUrl = (value: string) => { - return /^(?:(?:(?:https?|ftp):)?\/\/)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]{2,})))(?::\d{2,5})?(?:[/?#]\S*)?$/i.test( - value - ) + return /^(http|https):\/\/[^ "]+$/.test(value) } export default validateUrl