This is an automated email from the ASF dual-hosted git repository. aharui pushed a commit to branch webservice in repository https://gitbox.apache.org/repos/asf/royale-asjs.git
commit a75805220da1047867292cc473a46a7c69a87f40 Author: Alex Harui <[email protected]> AuthorDate: Thu Oct 3 14:16:07 2019 -0700 handle context root for JS at runtime --- .../MXRoyale/src/main/royale/mx/utils/URLUtil.as | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/frameworks/projects/MXRoyale/src/main/royale/mx/utils/URLUtil.as b/frameworks/projects/MXRoyale/src/main/royale/mx/utils/URLUtil.as index 4135705..4d86e1c 100644 --- a/frameworks/projects/MXRoyale/src/main/royale/mx/utils/URLUtil.as +++ b/frameworks/projects/MXRoyale/src/main/royale/mx/utils/URLUtil.as @@ -423,6 +423,17 @@ package mx.utils } } + COMPILE::JS + { + // Replace {context.root} + if (url.indexOf(CONTEXT_ROOT_TOKEN) > 0) + { + var contextRoot:String = LoaderConfig.contextRoot; + url = url.replace(CONTEXT_ROOT_REGEX, contextRoot); + } + } + + return url; } @@ -520,6 +531,17 @@ package mx.utils public static const SERVER_PORT_TOKEN:String = "{server.port}"; /** + * The pattern in the String that is passed to the <code>replaceTokens()</code> method that + * is replaced by the application's server name. + * + * @langversion 3.0 + * @playerversion Flash 9 + * @playerversion AIR 1.1 + * @productversion Flex 3 + */ + public static const CONTEXT_ROOT_TOKEN:String = "{context.root}"; + + /** * Enumerates an object's dynamic properties (by using a <code>for..in</code> loop) * and returns a String. You typically use this method to convert an ActionScript object to a String that you then append to the end of a URL. * By default, invalid URL characters are URL-encoded (converted to the <code>%XX</code> format). @@ -768,6 +790,7 @@ package mx.utils // we should handle server.name and server-name, etc... private static const SERVER_NAME_REGEX:RegExp = new RegExp("\\{server.name\\}", "g"); private static const SERVER_PORT_REGEX:RegExp = new RegExp("\\{server.port\\}", "g"); + private static const CONTEXT_ROOT_REGEX:RegExp = new RegExp("\\{context.root\\}", "g"); } } \ No newline at end of file
