linter
This commit is contained in:
parent
faca294079
commit
13633d15de
|
@ -41,14 +41,12 @@ const formidablePromise = async (req, opts) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const fileConsumer = (acc) => {
|
const fileConsumer = (acc) => {
|
||||||
const writable = new Writable({
|
return new Writable({
|
||||||
write: (chunk, _enc, next) => {
|
write: (chunk, _enc, next) => {
|
||||||
acc.push(chunk)
|
acc.push(chunk)
|
||||||
next()
|
next()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
return writable
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function handler(req, res) {
|
async function handler(req, res) {
|
||||||
|
|
|
@ -13,7 +13,7 @@ import validateUrl from '../../../utils/validateUrl'
|
||||||
export const ProfileSettingsPage = (props: PageProps) => {
|
export const ProfileSettingsPage = (props: PageProps) => {
|
||||||
const [addLinkForm, setAddLinkForm] = createSignal<boolean>(false)
|
const [addLinkForm, setAddLinkForm] = createSignal<boolean>(false)
|
||||||
const [incorrectUrl, setIncorrectUrl] = createSignal<boolean>(false)
|
const [incorrectUrl, setIncorrectUrl] = createSignal<boolean>(false)
|
||||||
const { form, updateFormField, submit, error } = useProfileForm()
|
const { form, updateFormField, submit, slugError } = useProfileForm()
|
||||||
const handleChangeSocial = (value) => {
|
const handleChangeSocial = (value) => {
|
||||||
if (validateUrl(value)) {
|
if (validateUrl(value)) {
|
||||||
updateFormField('links', value)
|
updateFormField('links', value)
|
||||||
|
@ -104,7 +104,7 @@ export const ProfileSettingsPage = (props: PageProps) => {
|
||||||
value={form.slug}
|
value={form.slug}
|
||||||
class="nolabel"
|
class="nolabel"
|
||||||
/>
|
/>
|
||||||
<p class="form-message form-message--error">{t(`error()`)}</p>
|
<p class="form-message form-message--error">{t(`${slugError()}`)}</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -10,13 +10,13 @@ const useProfileForm = () => {
|
||||||
const currentSlug = createMemo(() => session()?.user?.slug)
|
const currentSlug = createMemo(() => session()?.user?.slug)
|
||||||
const { authorEntities } = useAuthorsStore({ authors: [] })
|
const { authorEntities } = useAuthorsStore({ authors: [] })
|
||||||
const currentAuthor = createMemo(() => authorEntities()[currentSlug()])
|
const currentAuthor = createMemo(() => authorEntities()[currentSlug()])
|
||||||
const [error, setError] = createSignal<string>()
|
const [slugError, setSlugError] = createSignal<string>()
|
||||||
|
|
||||||
const submit = async (profile: ProfileInput) => {
|
const submit = async (profile: ProfileInput) => {
|
||||||
try {
|
try {
|
||||||
const response = await apiClient.updateProfile(profile)
|
const response = await apiClient.updateProfile(profile)
|
||||||
if (response.error) {
|
if (response.error) {
|
||||||
setError(response.error)
|
setSlugError(response.error)
|
||||||
return response.error
|
return response.error
|
||||||
}
|
}
|
||||||
return response
|
return response
|
||||||
|
@ -65,7 +65,7 @@ const useProfileForm = () => {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return { form, submit, updateFormField, error }
|
return { form, submit, updateFormField, slugError }
|
||||||
}
|
}
|
||||||
|
|
||||||
export { useProfileForm }
|
export { useProfileForm }
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
const validateUrl = (value: string) => {
|
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(
|
return /^(http|https):\/\/[^ "]+$/.test(value)
|
||||||
value
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default validateUrl
|
export default validateUrl
|
||||||
|
|
Loading…
Reference in New Issue
Block a user