Skip to content

Commit

Permalink
[grid] handle baseRoute like the hubRoute and the graphqlRoute (#13772)
Browse files Browse the repository at this point in the history
Co-authored-by: Diego Molina <diemol@users.noreply.github.com>
  • Loading branch information
joerg1985 and diemol committed Apr 6, 2024
1 parent 44eba59 commit 8c8adec
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,10 @@ private static Routable buildRoute(String url, String prefix, Function<String, R
}

protected static Routable baseRoute(String prefix, Route route) {
return Route.prefix(prefix).to(route);
if (prefix.isEmpty()) {
return route;
}
return Route.combine(route, Route.prefix(prefix).to(route));
}

protected abstract Handlers createHandlers(Config config);
Expand Down
6 changes: 1 addition & 5 deletions java/src/org/openqa/selenium/grid/commands/Hub.java
Original file line number Diff line number Diff line change
Expand Up @@ -187,16 +187,12 @@ protected Handlers createHandlers(Config config) {

Routable appendRoute =
Stream.of(
routerWithSpecChecks,
baseRoute(subPath, combine(routerWithSpecChecks)),
hubRoute(subPath, combine(routerWithSpecChecks)),
graphqlRoute(subPath, () -> graphqlHandler))
.reduce(Route::combine)
.get();

if (!subPath.isEmpty()) {
appendRoute = Route.combine(appendRoute, baseRoute(subPath, combine(routerWithSpecChecks)));
}

Routable httpHandler;
if (routerOptions.disableUi()) {
LOG.info("Grid UI has been disabled.");
Expand Down
6 changes: 1 addition & 5 deletions java/src/org/openqa/selenium/grid/commands/Standalone.java
Original file line number Diff line number Diff line change
Expand Up @@ -192,16 +192,12 @@ protected Handlers createHandlers(Config config) {

Routable appendRoute =
Stream.of(
router,
baseRoute(subPath, combine(router)),
hubRoute(subPath, combine(router)),
graphqlRoute(subPath, () -> graphqlHandler))
.reduce(Route::combine)
.get();

if (!subPath.isEmpty()) {
appendRoute = Route.combine(appendRoute, baseRoute(subPath, combine(router)));
}

Routable httpHandler;
if (routerOptions.disableUi()) {
LOG.info("Grid UI has been disabled.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,16 +149,12 @@ protected Handlers createHandlers(Config config) {

Routable appendRoute =
Stream.of(
routerWithSpecChecks,
baseRoute(subPath, combine(routerWithSpecChecks)),
hubRoute(subPath, combine(routerWithSpecChecks)),
graphqlRoute(subPath, () -> graphqlHandler))
.reduce(Route::combine)
.get();

if (!subPath.isEmpty()) {
appendRoute = Route.combine(appendRoute, baseRoute(subPath, combine(routerWithSpecChecks)));
}

Routable route;
if (routerOptions.disableUi()) {
LOG.info("Grid UI has been disabled.");
Expand Down

0 comments on commit 8c8adec

Please sign in to comment.