From cfbc7520b07d6ac189c58bcc31419ef37590d59e Mon Sep 17 00:00:00 2001 From: MaxKey Date: Sun, 25 Apr 2021 20:19:07 +0800 Subject: [PATCH] Update WebContext.java --- .../main/java/org/maxkey/web/WebContext.java | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/maxkey-core/src/main/java/org/maxkey/web/WebContext.java b/maxkey-core/src/main/java/org/maxkey/web/WebContext.java index 985f18d31..9627acea5 100644 --- a/maxkey-core/src/main/java/org/maxkey/web/WebContext.java +++ b/maxkey-core/src/main/java/org/maxkey/web/WebContext.java @@ -204,20 +204,22 @@ public final class WebContext { _logger.trace("ServerName " + httpServletRequest.getServerName()); String httpContextPath =""; - if (httpServletRequest.getServerName().matches(ipAddressRegex) ||httpServletRequest.getServerName().equalsIgnoreCase("localhost")) { - String scheme = httpServletRequest.getScheme().toLowerCase(); - httpContextPath = scheme + "://"+httpServletRequest.getServerName(); - int port = httpServletRequest.getServerPort(); - if(!(port==80 || port==443)){ - httpContextPath += ":"+port; - } - httpContextPath += httpServletRequest.getContextPath() + ""; + httpContextPath = httpServletRequest.getScheme().toLowerCase() + + "://"+httpServletRequest.getServerName(); + httpContextPath += httpServletRequest.getContextPath(); }else { - httpContextPath = applicationConfig.getServerName() + httpServletRequest.getContextPath() + ""; + httpContextPath = applicationConfig.getServerName() ; } + int port = httpServletRequest.getServerPort(); + if(!(port==80 || port==443)){ + httpContextPath += ":"+port; + } + + httpContextPath += httpServletRequest.getContextPath() + ""; + _logger.trace("httpContextPath " + httpContextPath); return httpContextPath;