new request layout bits
[nodejsws.git] / lib / wsrequest.js
index 021725b..a7ad086 100644 (file)
@@ -4,13 +4,13 @@ var fs = require("fs");
 var myparse = require("./myparse.js");
 var webmain = require("./webmain.js");
 
-var staticExtensions = ["html", "gif", "jpg", "css", "js", "ico"];
+//var staticExtensions = ["html", "gif", "jpg", "css", "js", "ico"];
 
 function wsRequest(request, response) {
        var isStatic = 0;
        var purl = url.parse(request.url);
        
-       staticExtensions.forEach(function testExtn(setest) {
+       /*staticExtensions.forEach(function testExtn(setest) {
                console.log("testing url: ", request.url);
                console.log("against: ", purl.pathname);
                var chk = purl.pathname.split(".");
@@ -20,12 +20,23 @@ function wsRequest(request, response) {
                if(chkid != -1) {
                        isStatic = 1;
                }
-       });
+       });*/
+       
+       // if the end of the pathname is something.something, we assume static
+       var lpath = purl.pathname.split("/").pop();
+       var idx = lpath.indexOf(".");
+       console.log("testing url: ", request.url);
+       console.log("against: ", purl.pathname);
+       console.log("lpath is: '%s'", lpath);
+       console.log("type is: '%s'", typeof lpath);
+       console.log("idx is: ", idx);
+       
+       if(idx > 0) isStatic = 1;
        
        if(isStatic == 1) {
                // do the static
-               var servethis = purl.pathname.split("/").pop();
-               serveStatic(servethis, response);
+               console.log("Service as static");
+               serveStatic(lpath, response);
                return;
        }