1
2
3
4
5
6
7
8
9
10
11
// SPDX-License-Identifier: 0BSD
export function appendFragment(fragment: string, html: string) {
if (!fragment) return html;
let offset = Math.min(
html.lastIndexOf("</body>"),
html.lastIndexOf("</html>"),
);
if (offset === -1) offset = html.length;
return html.slice(0, offset) + fragment + html.slice(offset);
}