aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/MainModule.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2022-08-08 18:30:56 -0700
committerAnton Tananaev <anton@traccar.org>2022-08-08 18:30:56 -0700
commit48a703302a8213402d5225d0087abc13521410a3 (patch)
treeb3252885b7852f3084542eded5347bc6faf1d949 /src/main/java/org/traccar/MainModule.java
parent90a6ae2affe642ced72a6a47fa0e0f919cbaeba3 (diff)
downloadtrackermap-server-48a703302a8213402d5225d0087abc13521410a3.tar.gz
trackermap-server-48a703302a8213402d5225d0087abc13521410a3.tar.bz2
trackermap-server-48a703302a8213402d5225d0087abc13521410a3.zip
Remove trailing URL slash
Diffstat (limited to 'src/main/java/org/traccar/MainModule.java')
-rw-r--r--src/main/java/org/traccar/MainModule.java20
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;