smolnar82 commented on code in PR #638:
URL: https://github.com/apache/knox/pull/638#discussion_r1060110657


##########
gateway-spi/src/main/java/org/apache/knox/gateway/util/URLUtils.java:
##########
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations 
under
+ * the License.
+ */
+package org.apache.knox.gateway.util;
+
+import java.net.URI;
+import java.net.URLDecoder;
+import java.nio.charset.StandardCharsets;
+
+public class URLUtils {
+
+  /**
+   * A method that decode url and concat query params, return result as URI.
+   *
+   * @param encoded encoded url
+   * @param queryStr query params
+   * @return decoded URI
+   */
+  public static URI getDecodeUri(String encoded, String queryStr) {
+    String decoded;
+    try {
+      decoded = URLDecoder.decode(encoded, StandardCharsets.UTF_8.name());
+    } catch (final Exception e) {
+      /* fall back in case of exception */
+      decoded = encoded;
+    }
+
+    final StringBuilder str = new StringBuilder(decoded);
+    if (queryStr != null) {

Review Comment:
   You may want to check for being `not blank` here 
(`StringUtils.isNotBlank(queryStr)`). Even if this is not null, it may be a 
blank string that makes no sense to append at the end of the decoded URI.



##########
gateway-spi/src/test/java/org/apache/knox/gateway/util/URLUtilsTest.java:
##########
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations 
under
+ * the License.
+ */
+package org.apache.knox.gateway.util;
+
+import org.junit.Test;
+
+import java.net.URI;
+
+import static org.junit.Assert.assertEquals;
+
+public class URLUtilsTest {

Review Comment:
   Please add other test cases with null and empty query strings.



##########
gateway-spi/src/main/java/org/apache/knox/gateway/util/URLUtils.java:
##########
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations 
under
+ * the License.
+ */
+package org.apache.knox.gateway.util;
+
+import java.net.URI;
+import java.net.URLDecoder;
+import java.nio.charset.StandardCharsets;
+
+public class URLUtils {
+
+  /**
+   * A method that decode url and concat query params, return result as URI.
+   *
+   * @param encoded encoded url
+   * @param queryStr query params
+   * @return decoded URI
+   */
+  public static URI getDecodeUri(String encoded, String queryStr) {

Review Comment:
   nit: I think there is a typo here; it should be `getDecodedUri` (note the 
`d` at the end of `Decoded`)or the method name should be changed to a verb: 
`decodeUri`



-- 
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]

Reply via email to