mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-01-23 16:41:22 +01:00
Changed redirection of root page
Changed Redirects From / -> "/server/" to /server/ServerName From /server/Unexisting -> "/server/" to "/server/ServerName" Affects issues: - Close 1210
This commit is contained in:
parent
f17470ee6c
commit
1b2342fe11
@ -16,6 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.djrapitops.plan.delivery.rendering.html;
|
package com.djrapitops.plan.delivery.rendering.html;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.commons.text.StringSubstitutor;
|
import org.apache.commons.text.StringSubstitutor;
|
||||||
import org.apache.commons.text.TextStringBuilder;
|
import org.apache.commons.text.TextStringBuilder;
|
||||||
|
|
||||||
@ -174,7 +175,10 @@ public enum Html {
|
|||||||
|
|
||||||
public static String encodeToURL(String string) {
|
public static String encodeToURL(String string) {
|
||||||
try {
|
try {
|
||||||
return URLEncoder.encode(string, "UTF-8");
|
return StringUtils.replace(
|
||||||
|
URLEncoder.encode(string, "UTF-8"),
|
||||||
|
"+", "%20" // Encoding replaces spaces with +
|
||||||
|
);
|
||||||
} catch (UnsupportedEncodingException e) {
|
} catch (UnsupportedEncodingException e) {
|
||||||
return string;
|
return string;
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,7 @@ import com.djrapitops.plan.delivery.webserver.auth.Authentication;
|
|||||||
import com.djrapitops.plan.delivery.webserver.response.Response;
|
import com.djrapitops.plan.delivery.webserver.response.Response;
|
||||||
import com.djrapitops.plan.delivery.webserver.response.ResponseFactory;
|
import com.djrapitops.plan.delivery.webserver.response.ResponseFactory;
|
||||||
import com.djrapitops.plan.exceptions.connection.WebException;
|
import com.djrapitops.plan.exceptions.connection.WebException;
|
||||||
|
import com.djrapitops.plan.identification.Server;
|
||||||
import com.djrapitops.plan.identification.ServerInfo;
|
import com.djrapitops.plan.identification.ServerInfo;
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
@ -50,8 +51,9 @@ public class RootPageHandler implements PageHandler {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Response getResponse(Request request, RequestTarget target) throws WebException {
|
public Response getResponse(Request request, RequestTarget target) throws WebException {
|
||||||
|
Server server = serverInfo.getServer();
|
||||||
if (!webServer.isAuthRequired()) {
|
if (!webServer.isAuthRequired()) {
|
||||||
return responseFactory.redirectResponse(serverInfo.getServer().isProxy() ? "network" : "server");
|
return responseFactory.redirectResponse(server.isProxy() ? "network" : "server/" + Html.encodeToURL(server.getIdentifiableName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
Optional<Authentication> auth = request.getAuth();
|
Optional<Authentication> auth = request.getAuth();
|
||||||
@ -64,7 +66,7 @@ public class RootPageHandler implements PageHandler {
|
|||||||
int permLevel = webUser.getPermLevel();
|
int permLevel = webUser.getPermLevel();
|
||||||
switch (permLevel) {
|
switch (permLevel) {
|
||||||
case 0:
|
case 0:
|
||||||
return responseFactory.redirectResponse(serverInfo.getServer().isProxy() ? "network" : "server");
|
return responseFactory.redirectResponse(server.isProxy() ? "network" : "server/" + Html.encodeToURL(server.getIdentifiableName()));
|
||||||
case 1:
|
case 1:
|
||||||
return responseFactory.redirectResponse("players");
|
return responseFactory.redirectResponse("players");
|
||||||
case 2:
|
case 2:
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.djrapitops.plan.delivery.webserver.pages;
|
package com.djrapitops.plan.delivery.webserver.pages;
|
||||||
|
|
||||||
|
import com.djrapitops.plan.delivery.rendering.html.Html;
|
||||||
import com.djrapitops.plan.delivery.webserver.Request;
|
import com.djrapitops.plan.delivery.webserver.Request;
|
||||||
import com.djrapitops.plan.delivery.webserver.RequestTarget;
|
import com.djrapitops.plan.delivery.webserver.RequestTarget;
|
||||||
import com.djrapitops.plan.delivery.webserver.WebServer;
|
import com.djrapitops.plan.delivery.webserver.WebServer;
|
||||||
@ -75,7 +76,8 @@ public class ServerPageHandler implements PageHandler {
|
|||||||
return responseFactory.serverPageResponse(serverUUID.get());
|
return responseFactory.serverPageResponse(serverUUID.get());
|
||||||
} else {
|
} else {
|
||||||
// Redirect to base server page.
|
// Redirect to base server page.
|
||||||
return responseFactory.redirectResponse(webServer.get().getAccessAddress() + (proxy ? "/network" : "/server"));
|
String directTo = proxy ? "/network" : "/server/" + Html.encodeToURL(serverInfo.getServer().getIdentifiableName());
|
||||||
|
return responseFactory.redirectResponse(webServer.get().getAccessAddress() + directTo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user