MetadataEncoder expands vars correctly
Closes gh-24656
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2019 the original author or authors.
|
* Copyright 2002-2020 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -51,7 +51,7 @@ import org.springframework.util.ObjectUtils;
|
|||||||
final class MetadataEncoder {
|
final class MetadataEncoder {
|
||||||
|
|
||||||
/** For route variable replacement. */
|
/** For route variable replacement. */
|
||||||
private static final Pattern VARS_PATTERN = Pattern.compile("\\{([^/]+?)}");
|
private static final Pattern VARS_PATTERN = Pattern.compile("\\{(.+?)}");
|
||||||
|
|
||||||
private static final Object NO_VALUE = new Object();
|
private static final Object NO_VALUE = new Object();
|
||||||
|
|
||||||
@@ -113,6 +113,7 @@ final class MetadataEncoder {
|
|||||||
matcher.appendReplacement(sb, value);
|
matcher.appendReplacement(sb, value);
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
|
matcher.appendTail(sb);
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2019 the original author or authors.
|
* Copyright 2002-2020 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -131,11 +131,11 @@ public class MetadataEncoderTests {
|
|||||||
public void routeWithVars() {
|
public void routeWithVars() {
|
||||||
DataBuffer buffer =
|
DataBuffer buffer =
|
||||||
new MetadataEncoder(MimeTypeUtils.TEXT_PLAIN, this.strategies)
|
new MetadataEncoder(MimeTypeUtils.TEXT_PLAIN, this.strategies)
|
||||||
.route("a.{b}.{c}", "BBB", "C.C.C")
|
.route("a.{b}.{c}.d", "BBB", "C.C.C")
|
||||||
.encode()
|
.encode()
|
||||||
.block();
|
.block();
|
||||||
|
|
||||||
assertThat(dumpString(buffer)).isEqualTo("a.BBB.C%2EC%2EC");
|
assertThat(dumpString(buffer)).isEqualTo("a.BBB.C%2EC%2EC.d");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
Reference in New Issue
Block a user