@cocreate/file-server 1.16.11 → 1.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ # [1.17.0](https://github.com/CoCreate-app/CoCreate-file-server/compare/v1.16.11...v1.17.0) (2024-09-08)
2
+
3
+
4
+ ### Features
5
+
6
+ * serve xml files and replaceAll {${host}} placeholders with requesting host ([7bda848](https://github.com/CoCreate-app/CoCreate-file-server/commit/7bda84882688c504e04c63e6f44546815754fe86))
7
+
1
8
  ## [1.16.11](https://github.com/CoCreate-app/CoCreate-file-server/compare/v1.16.10...v1.16.11) (2024-08-30)
2
9
 
3
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocreate/file-server",
3
- "version": "1.16.11",
3
+ "version": "1.17.0",
4
4
  "description": "A simple file-server component in vanilla javascript. Easily configured using HTML5 data-attributes and/or JavaScript API.",
5
5
  "keywords": [
6
6
  "file-server",
package/src/index.js CHANGED
@@ -145,7 +145,7 @@ class CoCreateFileSystem {
145
145
  }
146
146
 
147
147
  let contentType = file['content-type'] || 'text/html';
148
- // const cleanedSrc = src.replace(/\s/g, '');
148
+
149
149
  if (/^data:image\/[a-zA-Z0-9+.-]+;base64,([A-Za-z0-9+/]+={0,2})$/.test(src)) {
150
150
  src = src.replace(/^data:image\/(png|jpeg|jpg);base64,/, '');
151
151
  src = Buffer.from(src, 'base64');
@@ -155,8 +155,11 @@ class CoCreateFileSystem {
155
155
  try {
156
156
  src = await this.render.HTML(src, organization_id);
157
157
  } catch (err) {
158
- console.warn('server-render: ' + err.message)
158
+ console.warn('server-side-render: ' + err.message)
159
159
  }
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}`)
160
163
  }
161
164
 
162
165
  sendResponse(src, 200, { 'Content-Type': contentType })