mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
19 lines
450 B
JavaScript
19 lines
450 B
JavaScript
const validURL = str => {
|
|
const isValid = str.match(/^(?:https?:\/\/)(?:[^@\n])?(?:www\.)?([^:/\n?]+)/g)
|
|
return !!isValid
|
|
}
|
|
|
|
export default {
|
|
Mutation: {
|
|
CreateSocialMedia: async (resolve, root, args, context, info) => {
|
|
let socialMedia
|
|
if (validURL(args.url)) {
|
|
socialMedia = await resolve(root, args, context, info)
|
|
} else {
|
|
throw Error('Input is not a URL')
|
|
}
|
|
return socialMedia
|
|
}
|
|
}
|
|
}
|