From 6b85340ed46d3236bac68b505d77b40429261356 Mon Sep 17 00:00:00 2001 From: Mark Johnson Date: Fri, 7 Dec 2012 18:20:25 -0800 Subject: [PATCH] You can now override the scheme and domain of the appbase and latest URLs specified in your getdown.txt by setting the appbase_domain system property when launching getdown as an application --- .../threerings/getdown/data/Application.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/main/java/com/threerings/getdown/data/Application.java b/src/main/java/com/threerings/getdown/data/Application.java index 4fe5094..4b68ac0 100644 --- a/src/main/java/com/threerings/getdown/data/Application.java +++ b/src/main/java/com/threerings/getdown/data/Application.java @@ -501,6 +501,9 @@ public class Application _appbase = _appbase + "/"; } + // check if we're overriding the domain in the appbase + _appbase = replaceDomain(_appbase); + // extract our version information String vstr = (String)cdata.get("version"); if (vstr != null) { @@ -527,6 +530,7 @@ public class Application // check for a latest config URL String latest = (String)cdata.get("latest"); if (latest != null) { + latest = replaceDomain(latest); try { _latest = new URL(latest); } catch (MalformedURLException mue) { @@ -1620,6 +1624,19 @@ public class Application return cookie.toString(); } + /** + * If appbase_domain property is set, replace the domain on the provided string. + */ + protected String replaceDomain (String appbase) + { + String appbaseDomain = System.getProperty("appbase_domain"); + if (appbaseDomain != null) { + Matcher m = Pattern.compile("(http://[^/]+)(.*)").matcher(appbase); + appbase = m.replaceAll(appbaseDomain + "$2"); + } + return appbase; + } + protected File _appdir; protected String _appid; protected File _config;