A
A
Alexey Bolgov2020-08-04 23:55:10
JavaScript
Alexey Bolgov, 2020-08-04 23:55:10

How to disable scripts and links in nodejs?

Hello. Tell me how to remake preg_match for js script for chat to disable links and scripts?
Here is the code

if(preg_match("/href|url|http|https|www|.ru|.com|.net|.info|csgo|winner|ru|xyz|com|script|img|net|info|.org/i", $messages)) {
      return response()->json(['message' => 'Ссылки и скрипты запрещены!', 'status' => 'error']);
    }

$messages this will be msg

Here is an example js code where to implement
socket.on('create custom event', function(msg) {
        let json = JSON.parse(msg);

        currentSpecialEvent = {
            reward: 1,
            text: json.question
        };
        eventText = json.question;
        eventAnswer = json.answer;
        eventInterval = 300000;

        io.emit('event', JSON.stringify(currentSpecialEvent));
    });

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question