-
Feature Request
-
Resolution: Unresolved
-
Major
-
None
-
None
I was helping a developer convert some IIS rewrite rules over to use Undertow's predicate language and I found something interesting. Here is an excerpt from an IIS rewrite.
<rule name="LowerCase Rule" stopProcessing="true">
<match url="[A-Z]" ignoreCase="false" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{URL}" pattern="^.*\.(css|js|jpg|jpeg|png|gif|pdf|csv|xml|ttf|eot|svg|woff|ico|woff2|json|swf|xap|cfm)$" ignoreCase="true" negate="true" />
</conditions>
<action type="Redirect" url="{ToLower:{URL}}" redirectType="Permanent" />
</rule>
The interesting part here being the {ToLower:{URL}}
Undertow's Predicate language doesn't appear to have any sort of basic string manipulation functions like lower or upper casing.
It would appear IIS's rewrite module has out-of-the-box support for the following "string functions"
- toLower
- UrlEncode
- UrlDecode
which is quite odd that I don't see a "toUpper" in there!
https://docs.microsoft.com/en-us/iis/extensions/url-rewrite-module/url-rewrite-module-configuration-reference#string-functions
I recommend implementing these as exchange attributes themselves which can wrap another attribute (decorator pattern) in the format of
%{NameHere:attribute-to-wrap}
So an example would be:
%{toLower:%{METHOD}}
This would allow recursive nesting of transformations like so:
%{URLDecode:%{toLower:%{i,myHeader}}}
Please note, the exchange attribute parser needs a fix applied to allow parsing of an attribute that nests another attribute. https://issues.redhat.com/browse/UNDERTOW-2273
- is blocked by
-
UNDERTOW-2273 Exchange Attribute parser doesn't handle nested attributes
- Resolved
- is related to
-
UNDERTOW-2274 Allow exchange attributes which accept arbitrary text to accept nested exchange attributes
- Open