diff options
author | Daniel <djr2468@gmail.com> | 2023-04-05 22:29:32 +0100 |
---|---|---|
committer | Daniel <djr2468@gmail.com> | 2023-04-05 22:29:32 +0100 |
commit | 88a56f29fff1ab252a2c415f0d44a22192dd6b66 (patch) | |
tree | 119d616817ca314057c31df6848ee633fe99b467 /src/main/java/org/traccar/helper | |
parent | c0dd2a6187de517af33aa92e0524414e65d973b4 (diff) | |
download | trackermap-server-88a56f29fff1ab252a2c415f0d44a22192dd6b66.tar.gz trackermap-server-88a56f29fff1ab252a2c415f0d44a22192dd6b66.tar.bz2 trackermap-server-88a56f29fff1ab252a2c415f0d44a22192dd6b66.zip |
Implement retrieveWebUrl
Diffstat (limited to 'src/main/java/org/traccar/helper')
-rw-r--r-- | src/main/java/org/traccar/helper/WebHelper.java | 14 |
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), "", ""); + } + } } |