DEV Community

Dimitrios Desyllas
Dimitrios Desyllas

Posted on • Edited on

How I can verify that an incomming http body is multipart/form-data using regex and nodejs?

In my project I need to detect the content-type of http bodies ignoring the Content-Type header.

And I was stuck upon detecting multipart/form-data ones. After some tests, I used the regex in the question bellow:

At my nodejs project, I want to validate if an incoming http request is just a valid multipart/form-data one.

So far I tried the following example:

const http = require('http')
const validateMultipartFormData = (body) => {
   // Somehow use a logic to verify whether body is a multipart one.
   //

Top comments (0)