aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/helper/WebHelper.java
diff options
context:
space:
mode:
authorDaniel <djr2468@gmail.com>2023-04-05 22:29:32 +0100
committerDaniel <djr2468@gmail.com>2023-04-05 22:29:32 +0100
commit88a56f29fff1ab252a2c415f0d44a22192dd6b66 (patch)
tree119d616817ca314057c31df6848ee633fe99b467 /src/main/java/org/traccar/helper/WebHelper.java
parentc0dd2a6187de517af33aa92e0524414e65d973b4 (diff)
downloadtrackermap-server-88a56f29fff1ab252a2c415f0d44a22192dd6b66.tar.gz
trackermap-server-88a56f29fff1ab252a2c415f0d44a22192dd6b66.tar.bz2
trackermap-server-88a56f29fff1ab252a2c415f0d44a22192dd6b66.zip
Implement retrieveWebUrl
Diffstat (limited to 'src/main/java/org/traccar/helper/WebHelper.java')
-rw-r--r--src/main/java/org/traccar/helper/WebHelper.java14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/main/java/org/traccar/helper/WebHelper.java b/src/main/java/org/traccar/helper/WebHelper.java
index 9c6547d8d..e2844bc4d 100644
--- a/src/main/java/org/traccar/helper/WebHelper.java
+++ b/src/main/java/org/traccar/helper/WebHelper.java
@@ -48,4 +48,18 @@ public final class WebHelper {
return null;
}
}
+
+ public static String retrieveWebUrl(Config config) {
+ if (config.hasKey(Keys.WEB_URL)) {
+ return config.getString(Keys.WEB_URL).replaceAll("/$", "");
+ } else {
+ String address;
+ try {
+ address = config.getString(Keys.WEB_ADDRESS, InetAddress.getLocalHost().getHostAddress());
+ } catch (UnknownHostException e) {
+ address = "localhost";
+ }
+ return URIUtil.newURI("http", address, config.getInteger(Keys.WEB_PORT), "", "");
+ }
+ }
}