@sap-ux/preview-middleware 0.17.14 → 0.17.15

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.
Files changed (2) hide show
  1. package/dist/base/flp.js +8 -4
  2. package/package.json +8 -6
package/dist/base/flp.js CHANGED
@@ -238,8 +238,8 @@ class FlpSandbox {
238
238
  this.router.use(config_1.PREVIEW_URL.client.path, (0, express_1.static)(config_1.PREVIEW_URL.client.local));
239
239
  // add route for the sandbox html
240
240
  this.router.get(this.config.path, (async (req, res, next) => {
241
- // karma (connect API) has no request query property
242
- if (req.query && !req.query['sap-ui-xx-viewCache']) {
241
+ // connect API (karma test runner) has no request query property
242
+ if ('query' in req && 'redirect' in res && !req.query['sap-ui-xx-viewCache']) {
243
243
  // Redirect to the same URL but add the necessary parameter
244
244
  const params = structuredClone(req.query);
245
245
  params['sap-ui-xx-viewCache'] = 'false';
@@ -255,7 +255,11 @@ class FlpSandbox {
255
255
  next();
256
256
  }
257
257
  else {
258
- const ui5Version = await this.getUi5Version(req.protocol, req.headers.host, req['ui5-patched-router']?.baseUrl);
258
+ const ui5Version = await this.getUi5Version(
259
+ //use protocol from request header referer as fallback for connect API (karma test runner)
260
+ 'protocol' in req
261
+ ? req.protocol
262
+ : req.headers.referer?.substring(0, req.headers.referer.indexOf(':')) ?? 'http', req.headers.host, 'ui5-patched-router' in req ? req['ui5-patched-router']?.baseUrl : undefined);
259
263
  const html = (0, ejs_1.render)(this.getSandboxTemplate(ui5Version.major), this.templateConfig);
260
264
  this.sendResponse(res, 'text/html', 200, html);
261
265
  }
@@ -424,7 +428,7 @@ class FlpSandbox {
424
428
  const initTemplate = (0, fs_1.readFileSync)((0, path_1.join)(__dirname, '../../templates/test/testsuite.qunit.js'), 'utf-8');
425
429
  const config = (0, test_1.mergeTestConfigDefaults)(testsuiteConfig);
426
430
  this.logger.debug(`Add route for ${config.path}`);
427
- this.router.get(config.path, (async (_req, res) => {
431
+ this.router.get(config.path, (async (_req, res, _next) => {
428
432
  this.logger.debug(`Serving test route: ${config.path}`);
429
433
  const templateConfig = {
430
434
  basePath: this.templateConfig.basePath,
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  "bugs": {
10
10
  "url": "https://github.com/SAP/open-ux-tools/issues?q=is%3Aopen+is%3Aissue+label%3Abug+label%3Apreview-middleware"
11
11
  },
12
- "version": "0.17.14",
12
+ "version": "0.17.15",
13
13
  "license": "Apache-2.0",
14
14
  "author": "@SAP/ux-tools-team",
15
15
  "main": "dist/index.js",
@@ -25,14 +25,16 @@
25
25
  "ejs": "3.1.10",
26
26
  "mem-fs": "2.1.0",
27
27
  "mem-fs-editor": "9.4.0",
28
- "@sap-ux/logger": "0.6.0",
29
28
  "@sap-ux/feature-toggle": "0.2.3",
29
+ "@sap-ux/logger": "0.6.0",
30
30
  "@sap-ux/btp-utils": "1.0.0",
31
31
  "@sap-ux/adp-tooling": "0.12.121",
32
- "@sap-ux/control-property-editor-sources": "npm:@sap-ux/control-property-editor@0.5.33",
33
- "@sap-ux/project-access": "1.29.4"
32
+ "@sap-ux/project-access": "1.29.4",
33
+ "@sap-ux/control-property-editor-sources": "npm:@sap-ux/control-property-editor@0.5.33"
34
34
  },
35
35
  "devDependencies": {
36
+ "connect": "^3.7.0",
37
+ "@types/connect": "^3.4.38",
36
38
  "@types/ejs": "3.1.2",
37
39
  "@types/express": "4.17.21",
38
40
  "@types/prompts": "2.4.4",
@@ -47,10 +49,10 @@
47
49
  "@sap-ux-private/playwright": "0.1.0",
48
50
  "dotenv": "16.3.1",
49
51
  "@private/preview-middleware-client": "npm:@sap-ux-private/preview-middleware-client@0.11.56",
50
- "@sap-ux/axios-extension": "1.18.4",
51
52
  "@sap-ux/store": "1.0.0",
52
53
  "@sap-ux/ui5-info": "0.8.3",
53
- "@sap-ux/i18n": "0.2.0"
54
+ "@sap-ux/i18n": "0.2.0",
55
+ "@sap-ux/axios-extension": "1.18.4"
54
56
  },
55
57
  "peerDependencies": {
56
58
  "express": "4"