devongovett / rsc-html-stream

Inject an RSC payload into an HTML stream and read it back

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

mitigate end tag false positive detection?

dai-shi opened this issue · comments

Not sure, but is it safe to assume </body></html> appears just once?

-       controller.enqueue(encoder.encode(buf.replace('</body></html>', '')));
+       controller.enqueue(encoder.encode(buf.replace(/<\/body><\/html>$/, '')));

to be a little safer?

hmm not sure when there would be multiple bodies but good to be defensive I guess

yeah, maybe it would never happen with the output from React streaming.

if .endsWith('</body></html>') then .slice(0, -'</body></html>'.length)
might be faster, not only safer.
But, it's up to you.

Re: 603012a

- controller.enqueue(encoder.encode('</body></html>'));
+ controller.enqueue(encoder.encode(trailer));