Skip to content

Commit 7bda848

Browse files
committed
feat: serve xml files and replaceAll {${host}} placeholders with requesting host
1 parent 52adb99 commit 7bda848

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/index.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ class CoCreateFileSystem {
145145
}
146146

147147
let contentType = file['content-type'] || 'text/html';
148-
// const cleanedSrc = src.replace(/\s/g, '');
148+
149149
if (/^data:image\/[a-zA-Z0-9+.-]+;base64,([A-Za-z0-9+/]+={0,2})$/.test(src)) {
150150
src = src.replace(/^data:image\/(png|jpeg|jpg);base64,/, '');
151151
src = Buffer.from(src, 'base64');
@@ -155,8 +155,11 @@ class CoCreateFileSystem {
155155
try {
156156
src = await this.render.HTML(src, organization_id);
157157
} catch (err) {
158-
console.warn('server-render: ' + err.message)
158+
console.warn('server-side-render: ' + err.message)
159159
}
160+
} else if (contentType === 'text/xml' || contentType === 'application/xml') {
161+
const protocol = 'https://' // || req.headers['x-forwarded-proto'] || req.protocol;
162+
src = src.replaceAll('{{$host}}', `${protocol}${hostname}`)
160163
}
161164

162165
sendResponse(src, 200, { 'Content-Type': contentType })

0 commit comments

Comments
 (0)