mirror of https://github.com/halo-dev/halo
[release-2.1] Fix the problem of slug name with percent sign when publishing post (#3183)
This is an automated cherry-pick of #3179 /assign ruibaby ```release-note 修复因别名包含百分号导致无法正常访问的问题 ```pull/3417/head
parent
6dfc2f46e0
commit
2e491e025f
|
@ -31,9 +31,7 @@ public class RadixRouterTree extends RadixTree<HandlerFunction<ServerResponse>>
|
|||
@Override
|
||||
public void insert(String key, HandlerFunction<ServerResponse> value)
|
||||
throws IllegalArgumentException {
|
||||
// uri decode key to insert
|
||||
String decodedKey = UriUtils.decode(key, StandardCharsets.UTF_8);
|
||||
super.insert(decodedKey, value);
|
||||
super.insert(key, value);
|
||||
if (log.isDebugEnabled()) {
|
||||
checkIndices();
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ import java.net.URISyntaxException;
|
|||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.mock.web.reactive.function.server.MockServerRequest;
|
||||
import org.springframework.web.reactive.function.server.ServerResponse;
|
||||
|
||||
/**
|
||||
* Tests for {@link RadixRouterTree}.
|
||||
|
@ -41,4 +42,10 @@ class RadixRouterTreeTest {
|
|||
.method(HttpMethod.GET).build();
|
||||
assertThat(RadixRouterTree.pathToFind(request)).isEqualTo("/?p=fake-post");
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldInsertKeyWithPercentSign() {
|
||||
var tree = new RadixRouterTree();
|
||||
tree.insert("/1%1", request -> ServerResponse.ok().build());
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue