diff options
author | Anton Tananaev <anton@traccar.org> | 2022-08-08 18:30:56 -0700 |
---|---|---|
committer | Anton Tananaev <anton@traccar.org> | 2022-08-08 18:30:56 -0700 |
commit | 48a703302a8213402d5225d0087abc13521410a3 (patch) | |
tree | b3252885b7852f3084542eded5347bc6faf1d949 /src/main/java/org | |
parent | 90a6ae2affe642ced72a6a47fa0e0f919cbaeba3 (diff) | |
download | trackermap-server-48a703302a8213402d5225d0087abc13521410a3.tar.gz trackermap-server-48a703302a8213402d5225d0087abc13521410a3.tar.bz2 trackermap-server-48a703302a8213402d5225d0087abc13521410a3.zip |
Remove trailing URL slash
Diffstat (limited to 'src/main/java/org')
-rw-r--r-- | src/main/java/org/traccar/MainModule.java | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/main/java/org/traccar/MainModule.java b/src/main/java/org/traccar/MainModule.java index b8ff21472..e0617a734 100644 --- a/src/main/java/org/traccar/MainModule.java +++ b/src/main/java/org/traccar/MainModule.java @@ -318,17 +318,19 @@ public class MainModule extends AbstractModule { properties.setProperty("file.resource.loader.path", config.getString(Keys.TEMPLATES_ROOT) + "/"); properties.setProperty("runtime.log.logsystem.class", NullLogChute.class.getName()); - String address; - try { - address = config.getString(Keys.WEB_ADDRESS, InetAddress.getLocalHost().getHostAddress()); - } catch (UnknownHostException e) { - address = "localhost"; + if (config.hasKey(Keys.WEB_URL)) { + properties.setProperty("web.url", config.getString(Keys.WEB_URL).replaceAll("/$", "")); + } else { + String address; + try { + address = config.getString(Keys.WEB_ADDRESS, InetAddress.getLocalHost().getHostAddress()); + } catch (UnknownHostException e) { + address = "localhost"; + } + String url = URIUtil.newURI("http", address, config.getInteger(Keys.WEB_PORT), "", ""); + properties.setProperty("web.url", url); } - String url = config.getString( - Keys.WEB_URL, URIUtil.newURI("http", address, config.getInteger(Keys.WEB_PORT), "", "")); - properties.setProperty("web.url", url); - VelocityEngine velocityEngine = new VelocityEngine(); velocityEngine.init(properties); return velocityEngine; |