File tree Expand file tree Collapse file tree 2 files changed +39
-3
lines changed Expand file tree Collapse file tree 2 files changed +39
-3
lines changed Original file line number Diff line number Diff line change @@ -39,10 +39,9 @@ public final class Expressions {
39
39
*
40
40
* <p>This is not a complete implementation of the rfc
41
41
*
42
- * <p><a href="https://www.rfc-editor.org/rfc/rfc6570#section-2.2>RFC 6570 Expressions</a>
42
+ * <p><a href="https://www.rfc-editor.org/rfc/rfc6570#section-2.2" >RFC 6570 Expressions</a>
43
43
*/
44
- private static final Pattern EXPRESSION_PATTERN =
45
- Pattern .compile ("^(\\ {([+#./;?&=,!@|]?)(.+)})$" );
44
+ static final Pattern EXPRESSION_PATTERN = Pattern .compile ("^(\\ {([+#./;?&=,!@|]?)(.+)\\ })$" );
46
45
47
46
// Partially From:
48
47
// https://stackoverflow.com/questions/29494608/regex-for-uri-templates-rfc-6570-wanted -- I
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright 2012-2023 The Feign Authors
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5
+ * in compliance with the License. You may obtain a copy of the License at
6
+ *
7
+ * http://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
10
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11
+ * or implied. See the License for the specific language governing permissions and limitations under
12
+ * the License.
13
+ */
14
+ package feign .template ;
15
+
16
+ import static org .assertj .core .api .Assertions .assertThat ;
17
+
18
+ import java .util .Collections ;
19
+ import org .junit .jupiter .api .Test ;
20
+
21
+ public class ExpressionsTest {
22
+
23
+ @ Test
24
+ public void simpleExpression () {
25
+ Expression expression = Expressions .create ("{foo}" );
26
+ assertThat (expression ).isNotNull ();
27
+ String expanded = expression .expand (Collections .singletonMap ("foo" , "bar" ), false );
28
+ assertThat (expanded ).isEqualToIgnoringCase ("foo=bar" );
29
+ }
30
+
31
+ @ Test
32
+ public void androidCompatibility () {
33
+ // To match close brace on Android, it must be escaped due to the simpler ICU regex engine
34
+ String pattern = Expressions .EXPRESSION_PATTERN .pattern ();
35
+ assertThat (pattern .contains ("}" )).isEqualTo (pattern .contains ("\\ }" ));
36
+ }
37
+ }
You can’t perform that action at this time.
0 commit comments