@sap-ux/ui5-proxy-middleware 1.6.1 → 1.6.2

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.
@@ -134,6 +134,10 @@ export declare function proxyErrorHandler(err: Error & {
134
134
  export declare function directLoadProxy(ui5Configs: ProxyConfig[], rootProject: ReaderCollection, logger: ToolsLogger): RequestHandler;
135
135
  /**
136
136
  * Create a rewrite based on the provided configuration.
137
+ * This will either replace the configured path with the provided pathReplace value or
138
+ * will prepend the UI5 version to the path.
139
+ * It also ensures that the path from the http-proxy-middleware starts with the
140
+ * config path in case of nested router instances.
137
141
  *
138
142
  * @param config proxy configuration
139
143
  * @param ui5Ver UI5 version string
@@ -313,6 +313,10 @@ function directLoadProxy(ui5Configs, rootProject, logger) {
313
313
  }
314
314
  /**
315
315
  * Create a rewrite based on the provided configuration.
316
+ * This will either replace the configured path with the provided pathReplace value or
317
+ * will prepend the UI5 version to the path.
318
+ * It also ensures that the path from the http-proxy-middleware starts with the
319
+ * config path in case of nested router instances.
316
320
  *
317
321
  * @param config proxy configuration
318
322
  * @param ui5Ver UI5 version string
@@ -322,7 +326,9 @@ function getPathRewrite(config, ui5Ver) {
322
326
  if (config.pathReplace) {
323
327
  // Remove trailing slash from pathReplace if present
324
328
  const sanitizedPathReplace = config.pathReplace?.replace(/\/$/, '');
325
- return (path) => path.replace(config.path, sanitizedPathReplace);
329
+ return (path) => path.startsWith(config.path)
330
+ ? path.replace(config.path, sanitizedPathReplace)
331
+ : sanitizedPathReplace + path;
326
332
  }
327
333
  return (path) => (path.startsWith(config.path) ? ui5Ver + path : ui5Ver + config.path + path);
328
334
  }
@@ -87,6 +87,7 @@ module.exports = async ({ resources, options }) => {
87
87
  path: ui5Path,
88
88
  url: envUI5Url || ui5.url,
89
89
  version: ui5Version,
90
+ pathReplace: ui5.pathReplace,
90
91
  proxy: config.proxy
91
92
  };
92
93
  routes.push({ route: ui5Config.path, handler: (0, base_1.ui5Proxy)(ui5Config, proxyOptions, undefined, logger) });
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%3Aui5-proxy-middleware"
11
11
  },
12
- "version": "1.6.1",
12
+ "version": "1.6.2",
13
13
  "license": "Apache-2.0",
14
14
  "author": "@SAP/ux-tools-team",
15
15
  "main": "dist/index.js",
@@ -27,7 +27,7 @@
27
27
  "i18next": "25.3.0",
28
28
  "proxy-from-env": "1.1.0",
29
29
  "@sap-ux/logger": "0.7.0",
30
- "@sap-ux/ui5-config": "0.29.5"
30
+ "@sap-ux/ui5-config": "0.29.6"
31
31
  },
32
32
  "devDependencies": {
33
33
  "@types/express": "4.17.21",
@@ -37,7 +37,7 @@
37
37
  "nock": "13.4.0",
38
38
  "supertest": "7.1.4",
39
39
  "yaml": "2.2.2",
40
- "@sap-ux/project-access": "1.32.1"
40
+ "@sap-ux/project-access": "1.32.2"
41
41
  },
42
42
  "ui5": {
43
43
  "dependencies": []