     file = file.replace(/\?.*$/i, '')     #remove ?random= - or other urlparams
       
     file_extension = file.match(/\.([^\.]*)$/i)
-    if !file_extension[0]
+    if file_extension && file_extension[0]
+      file_extension = file_extension[1].toLowerCase()
+    else
       file_extension = 'json'
-    else
-      file_extension = file_extension[1].toLowerCase()
     
     if ! filetype[file_extension]
       file_extension = 'index'
       file = 'index.html'
-      #TODO: do something to load the right page (and here we start with html templating
+      #TODO: modify the index.html page div id
     
     encoding = filetype[file_extension]['encoding']
     contentType =  filetype[file_extension]['content_type']

    #and here's a pointless exception to the filename.extension :(
    filePath = filePath.replace(/\.json/, '') if file_extension == 'json'
    
    console.log req.method+filePath
    
    fs.readFile filePath, encoding, (err, data) ->
      status = 200
      if err

}

process.serve_url = (req, res) ->
#work out what resource the request is about
    file = req.url[1..]

    if req.method == 'PUT'
       #nasty hack, as we're only putting pages atm, and the URI's are :(
       file = file.replace(/^page\//, '')    #TODO: mmm, substring anyone?
       file = file.replace(/\/action$/, '')
    
    if file == ''
      console.log 'getting / == welcome-visitors.html topic'
