From 5e95a7b34a4c0ab0ea4d9256c5134bf0a3d78b22 Mon Sep 17 00:00:00 2001 From: Phillip Kruger Date: Thu, 11 Apr 2024 15:12:05 +1000 Subject: [PATCH] Fix url encoding issue for Dev UI Page with funny chars Signed-off-by: Phillip Kruger --- .../resources/dev-ui/controller/router-controller.js | 1 - .../src/main/java/io/quarkus/devui/spi/page/Page.java | 9 +++++++++ .../main/java/io/quarkus/devui/spi/page/PageBuilder.java | 5 ++++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/extensions/vertx-http/dev-ui-resources/src/main/resources/dev-ui/controller/router-controller.js b/extensions/vertx-http/dev-ui-resources/src/main/resources/dev-ui/controller/router-controller.js index a70a2a0efd2e9..3fd5f879c6e6d 100644 --- a/extensions/vertx-http/dev-ui-resources/src/main/resources/dev-ui/controller/router-controller.js +++ b/extensions/vertx-http/dev-ui-resources/src/main/resources/dev-ui/controller/router-controller.js @@ -176,7 +176,6 @@ export class RouterController { addRoute(path, component, name, page, defaultRoute = false) { path = this.getPageUrlFor(page); - var currentSelection = window.location.pathname; const search = new URLSearchParams(window.location.search); if (!this.isExistingPath(path)) { RouterController.pageMap.set(path, page); diff --git a/extensions/vertx-http/dev-ui-spi/src/main/java/io/quarkus/devui/spi/page/Page.java b/extensions/vertx-http/dev-ui-spi/src/main/java/io/quarkus/devui/spi/page/Page.java index 247b2986f1c14..e7cb77009afbf 100644 --- a/extensions/vertx-http/dev-ui-spi/src/main/java/io/quarkus/devui/spi/page/Page.java +++ b/extensions/vertx-http/dev-ui-spi/src/main/java/io/quarkus/devui/spi/page/Page.java @@ -1,5 +1,8 @@ package io.quarkus.devui.spi.page; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; import java.util.Map; /** @@ -61,6 +64,12 @@ protected Page(String icon, public String getId() { String id = this.title.toLowerCase().replaceAll(SPACE, DASH); + try { + id = URLEncoder.encode(id, StandardCharsets.UTF_8.toString()); + } catch (UnsupportedEncodingException ex) { + throw new RuntimeException(ex); + } + if (!this.isInternal() && this.namespace != null) { // This is extension pages in Dev UI id = this.namespace.toLowerCase() + SLASH + id; diff --git a/extensions/vertx-http/dev-ui-spi/src/main/java/io/quarkus/devui/spi/page/PageBuilder.java b/extensions/vertx-http/dev-ui-spi/src/main/java/io/quarkus/devui/spi/page/PageBuilder.java index 0e77a50ca6b73..823fd87570a83 100644 --- a/extensions/vertx-http/dev-ui-spi/src/main/java/io/quarkus/devui/spi/page/PageBuilder.java +++ b/extensions/vertx-http/dev-ui-spi/src/main/java/io/quarkus/devui/spi/page/PageBuilder.java @@ -42,7 +42,10 @@ public T title(String title) { @SuppressWarnings("unchecked") public T staticLabel(String staticLabel) { - this.staticLabel = staticLabel; + if (this.staticLabel == null) { + this.staticLabel = ""; + } + this.staticLabel = this.staticLabel + " " + staticLabel; return (T) this; }