bonampak commented on code in PR #1497:
URL: https://github.com/apache/knox/pull/1497#discussion_r4540800059
##########
gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/impl/UrlRewriteUtil.java:
##########
@@ -60,13 +60,46 @@ public static UrlRewriteFilterContentDescriptor
getRewriteFilterConfig(
public static String filterJavaScript( String inputValue,
UrlRewriteFilterContentDescriptor config,
UrlRewriteFilterReader filterReader,
UrlRewriteFilterPathDescriptor.Compiler<Pattern> regexCompiler ) {
+ return filterMatches( inputValue, config, filterReader, regexCompiler,
false );
+ }
+
+ /**
+ * Rewrites every match of the applies that are configured with find, the
rest of the input is left untouched.
+ * Applies without find have to match a whole value, they are not used here.
+ */
+ public static String filterFind( String inputValue,
UrlRewriteFilterContentDescriptor config,
+ UrlRewriteFilterReader filterReader,
UrlRewriteFilterPathDescriptor.Compiler<Pattern> regexCompiler ) {
+ return filterMatches( inputValue, config, filterReader, regexCompiler,
true );
+ }
+
+ public static boolean hasFindApply( UrlRewriteFilterContentDescriptor config
) {
+ if( config != null ) {
+ for( UrlRewriteFilterPathDescriptor selector : config.getSelectors() ) {
+ if( selector instanceof UrlRewriteFilterApplyDescriptor &&
((UrlRewriteFilterApplyDescriptor)selector).find() ) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ /*
+ * The applies are processed one after the other and every apply searches
the output of the previous one, so an
Review Comment:
I went with the dev guide option.
Applies are chained on purpose, the same as for JS content, so there's one
behavior to document.
I've added a note to the dev guide that several partial applies are chained
and their paths must be disjoint/anchored, plus a complete example with a rule
and an anchored path.
If a real need for several overlapping partial applies comes up, "rewrite
each part at most once" can be added then; it would only change configs that
already rewrite twice.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]