mountPath for middleware is not supporting array or regex
Expected Behavior
Support arrays for mountPath just like express does
Current Behavior
It's not supported
Steps to Reproduce the Issue
- add middleware with array definition for mountPath
- name: ui5-middleware-simpleproxy
afterMiddleware: ui5-middleware-stringreplacer
mountPath:
- '/ci/'
- '/v2/'
- '/sf/'
Context
- UI5 Module Version (output of
ui5 --versionwhen using the CLI): 2.13 - Node.js Version:
14 - npm Version:
8.1
Log Output / Stack Trace
Configuration server/customMiddleware/1/mountPath must be of type 'string'
/home/pieter/projects/xxx/app/ui5.yaml:17
15: - name: ui5-middleware-simpleproxy
16: afterMiddleware: compression
17: mountPath:
I tried a regex, but that doesn't seem to be recongized as regex and fails when the path is converted to a regex:
mountPath: /\/(ci|v2|sf){1}\/.*/
Stack Trace:
SyntaxError: Invalid regular expression: /^\/\\/(?(?:([^\/]+?))|v2|sf){1}\\/\.(.*)\/?(?=\/|$)/: Invalid group
at new RegExp (<anonymous>)
at pathtoRegexp (/home/pieter/projects/xxx/app/node_modules/@ui5/cli/node_modules/path-to-regexp/index.js:128:10)
Sounds reasonable. This is only limited by our schema.
@matz3 can you think of any reasons against allowing arrays and regular expressions here as well?
Also see our documentation:
An optional mountPath for which the middleware function is invoked can be provided. It will be passed to the
app.usecall (see express API reference).
@RandomByte an array should be fine. I just wonder about a regular expression. YAML/JSON don't support RegExp, so we would need to differentiate between a RegExp pattern and a string or path pattern.