I have an if function that checks if the link doesn't break the rules:
const file = data.file.toLowerCase()
if(!file.startsWith('https://')
|| !file.endsWith('.gif')
|| !file.endsWith('.png')
|| !file.endsWith('.jpg')
|| !file.endsWith('mp4')
|| !file.endsWith('mp3')
|| !file.endsWith('.webm')
)
return
This makes other code not run, even if the link doesn't break the rules. Can anyone help?
!file.endsWith('.gif') || !file.endsWith('.png') ...
This will always return true as a string can end with .gif (which matches !file.endsWith('.png') ), .png (which matches !file.endsWith('.gif')), or other things that will match both. Therefore the return will always run.
You may instead need &&