You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by da...@apache.org on 2016/05/30 10:29:55 UTC

[1/2] cordova-lib git commit: CB-11274 Make serve dashboard take config.xml -> content.src entry point into account

Repository: cordova-lib
Updated Branches:
  refs/heads/master 0e15ab45a -> 0668ac05a


CB-11274 Make serve dashboard take config.xml -> content.src entry point into account


Project: http://git-wip-us.apache.org/repos/asf/cordova-lib/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-lib/commit/dcc44c8b
Tree: http://git-wip-us.apache.org/repos/asf/cordova-lib/tree/dcc44c8b
Diff: http://git-wip-us.apache.org/repos/asf/cordova-lib/diff/dcc44c8b

Branch: refs/heads/master
Commit: dcc44c8b0226245dc6cdd70ff0e4ab51ad7fb2b4
Parents: 0e15ab4
Author: daserge <v-...@microsoft.com>
Authored: Mon May 23 13:20:26 2016 +0300
Committer: daserge <v-...@microsoft.com>
Committed: Wed May 25 14:33:07 2016 +0300

----------------------------------------------------------------------
 cordova-lib/src/cordova/serve.js | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/dcc44c8b/cordova-lib/src/cordova/serve.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/serve.js b/cordova-lib/src/cordova/serve.js
index e24e990..2c4bba7 100644
--- a/cordova-lib/src/cordova/serve.js
+++ b/cordova-lib/src/cordova/serve.js
@@ -41,6 +41,9 @@ function handleRoot(request, response, next) {
 
     response.writeHead(200, {'Content-Type': 'text/html'});
     var config = new ConfigParser(cordova_util.projectConfig(projectRoot));
+    var contentNode = config.doc.find('content');
+    var contentSrc = contentNode && contentNode.attrib.src || 'index.html';
+
     response.write('<html><head><title>' + config.name() + '</title></head><body>');
     response.write('<table border cellspacing=0><thead><caption><h3>Package Metadata</h3></caption></thead><tbody>');
     ['name', 'packageName', 'version'].forEach(function (c) {
@@ -50,7 +53,7 @@ function handleRoot(request, response, next) {
     response.write('<h3>Platforms</h3><ul>');
     Object.keys(platforms).forEach(function (platform) {
         if (installedPlatforms.indexOf(platform) >= 0) {
-            response.write('<li><a href="' + platform + '/www/">' + platform + '</a></li>\n');
+            response.write('<li><a href="' + platform + '/www/' + contentSrc + '">' + platform + '</a></li>\n');
         } else {
             response.write('<li><em>' + platform + '</em></li>\n');
         }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


[2/2] cordova-lib git commit: CB-11274 Platform browser: wrong path for config.xml

Posted by da...@apache.org.
CB-11274 Platform browser: wrong path for config.xml

Added redirection to the referer' platform content to resolve an URL against that platform www directory


Project: http://git-wip-us.apache.org/repos/asf/cordova-lib/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-lib/commit/0668ac05
Tree: http://git-wip-us.apache.org/repos/asf/cordova-lib/tree/0668ac05
Diff: http://git-wip-us.apache.org/repos/asf/cordova-lib/diff/0668ac05

Branch: refs/heads/master
Commit: 0668ac05a25afdc4b1817c7c7ca9191d86d4662f
Parents: dcc44c8
Author: daserge <v-...@microsoft.com>
Authored: Tue May 24 17:06:56 2016 +0300
Committer: daserge <v-...@microsoft.com>
Committed: Wed May 25 14:33:17 2016 +0300

----------------------------------------------------------------------
 cordova-lib/src/cordova/serve.js | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/0668ac05/cordova-lib/src/cordova/serve.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/serve.js b/cordova-lib/src/cordova/serve.js
index 2c4bba7..114edb5 100644
--- a/cordova-lib/src/cordova/serve.js
+++ b/cordova-lib/src/cordova/serve.js
@@ -93,6 +93,28 @@ function getPlatformHandler(platform, wwwDir, configXml) {
     };
 }
 
+// https://issues.apache.org/jira/browse/CB-11274
+// Use referer url to redirect absolute urls to the requested platform resources
+// so that an URL is resolved against that platform www directory.
+function getAbsolutePathHandler() {
+    return function (request, response, next) {
+        if (!request.headers.referer) {
+            next();
+            return;
+        }
+
+        var pathname = url.parse(request.headers.referer).pathname;
+        var platform = pathname.split('/')[1];
+
+        if (installedPlatforms.indexOf(platform) >= 0 &&
+            request.originalUrl.indexOf(platform) === -1) {
+            response.redirect('/' + platform + '/www' + request.originalUrl);
+        } else {
+            next();
+        }
+    };
+}
+
 function calculateMd5(fileName) {
     var md5sum,
         BUF_LENGTH = 64*1024,
@@ -133,6 +155,8 @@ module.exports = function server(port, opts) {
                 server.app.use('/' + platform + '/www', serve.static(locations.www));
                 server.app.get('/' + platform + '/*', getPlatformHandler(platform, locations.www, locations.configXml));
             });
+
+            server.app.get('/*', getAbsolutePathHandler());
             server.app.get('*', handleRoot);
 
             server.launchServer({port: port, events: events});


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org