Skip to content

Commit

Permalink
Merge pull request #2927 from glific/fix/interactive-messages
Browse files Browse the repository at this point in the history
Fixed validation of url in interactive messages
  • Loading branch information
kurund authored Jun 12, 2024
2 parents 1074282 + 99721b3 commit 95affd6
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/containers/InteractiveMessage/InteractiveMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,13 @@ import { EmojiInput } from 'components/UI/Form/EmojiInput/EmojiInput';
import { AutoComplete } from 'components/UI/Form/AutoComplete/AutoComplete';
import { Simulator } from 'components/simulator/Simulator';
import { LanguageBar } from 'components/UI/LanguageBar/LanguageBar';
import { LIST, LOCATION_REQUEST, MEDIA_MESSAGE_TYPES, QUICK_REPLY } from 'common/constants';
import {
LIST,
LOCATION_REQUEST,
MEDIA_MESSAGE_TYPES,
QUICK_REPLY,
VALID_URL_REGEX,
} from 'common/constants';
import { validateMedia } from 'common/utils';
import { Loading } from 'components/UI/Layout/Loading/Loading';
import { InteractiveOptions } from './InteractiveOptions/InteractiveOptions';
Expand Down Expand Up @@ -254,7 +260,10 @@ export const InteractiveMessage = () => {
}

if (isEditing && data.attachmentURL) {
setDynamicMedia(!isUrlValid);
const testForValidUrl = new RegExp(VALID_URL_REGEX, 'gi');
if (!testForValidUrl.test(data.attachmentURL)) {
setDynamicMedia(true);
}
}

if (translationsVal) {
Expand Down Expand Up @@ -286,7 +295,7 @@ export const InteractiveMessage = () => {
if (!dynamicMedia && (type === '' || type) && attachmentURL) {
validateURL(attachmentURL);
}
}, [type, attachmentURL]);
}, [type, attachmentURL, dynamicMedia]);

const handleAddInteractiveTemplate = (
addFromTemplate: boolean,
Expand Down

0 comments on commit 95affd6

Please sign in to comment.