Author: [email protected]
Date: Tue Jun 23 12:43:56 2009
New Revision: 5613

Modified:
    trunk/dev/oophm/src/com/google/gwt/dev/OophmHostedModeBase.java

Log:
Fix how the launch URL is built to include the gwt.hosted parameter
(previously it would build it improperly if the launch URL had a
fragment).

Patch by: jat
Review by: jgw (desk)


Modified: trunk/dev/oophm/src/com/google/gwt/dev/OophmHostedModeBase.java
==============================================================================
--- trunk/dev/oophm/src/com/google/gwt/dev/OophmHostedModeBase.java      
(original)
+++ trunk/dev/oophm/src/com/google/gwt/dev/OophmHostedModeBase.java     Tue Jun 
 
23 12:43:56 2009
@@ -36,6 +36,7 @@
  import java.awt.event.WindowEvent;
  import java.io.IOException;
  import java.io.PrintWriter;
+import java.net.MalformedURLException;
  import java.net.URL;
  import java.util.IdentityHashMap;
  import java.util.Map;
@@ -294,13 +295,27 @@
       * TODO(jat): properly support launching arbitrary browsers; waiting on
       * Freeland's work with BrowserScanner and the trunk merge to get it.
       */
-    String separator;
-    if (url.contains("?")) {
-      separator = "&";
-    } else {
-      separator = "?";
+    try {
+      URL parsedUrl = new URL(url);
+      String path = parsedUrl.getPath();
+      String query = parsedUrl.getQuery();
+      String hash = parsedUrl.getRef();
+      String hostedParam =  "gwt.hosted=" +  
listener.getEndpointIdentifier();
+      if (query == null) {
+        query = hostedParam;
+      } else {
+        query += '&' + hostedParam;
+      }
+      path += '?' + query;
+      if (hash != null) {
+        path += '#' + hash;
+      }
+      url = new URL(parsedUrl.getProtocol(), parsedUrl.getHost(),
+          parsedUrl.getPort(), path).toExternalForm();
+    } catch (MalformedURLException e) {
+      getTopLogger().log(TreeLogger.ERROR, "Invalid URL " + url, e);
+      throw new UnableToCompleteException();
      }
-    url += separator + "gwt.hosted=" + listener.getEndpointIdentifier();
      TreeLogger branch = getTopLogger().branch(TreeLogger.INFO,
          "Launching firefox with " + url, null);
      try {

--~--~---------~--~----~------------~-------~--~----~
http://groups.google.com/group/Google-Web-Toolkit-Contributors
-~----------~----~----~----~------~----~------~--~---

Reply via email to