elysiajs / elysia-html

A plugin for Elysia that add support for returning html
MIT License
25 stars 18 forks source link

Regexp to detect HTML is stateful #11

Closed gtramontina closed 1 year ago

gtramontina commented 1 year ago

The regular expression to detect whether the content resambles HTML uses the global flag, which makes it stateful. So, from time to time (depending on the content-length) the regular expression finally reaches the end and returns false.

gtramontina commented 1 year ago

Although there's a fix on #12, it seems to me that a slightly more reliable check would be to look for <!doctype html> or <html>.