testing/mochitest/dynamic/getMyDirectory.sjs
author Robert Sayre <sayrer@gmail.com>
Thu, 06 Jan 2011 21:38:46 -0500
changeset 60192 1cd2c3d9f5623b4e8958eaaf3cf79d38e78b1a64
parent 38671 40326c4f714c69b4beefe90d39c3cf1638060ff1
child 101261 ba9e4b81d7f60615ad111586a184e3bbcdb9a1c7
permissions -rw-r--r--
Backed out changeset 39ccae4efa0f

function handleRequest(request, response)
{
  var file;
  getObjectState("SERVER_ROOT", function(serverRoot)
  {
    var ref = request.getHeader("Referer");
    // 8 is "https://".length which is the longest string before the host.
    var pathStart = ref.indexOf("/", 8) + 1;
    var pathEnd = ref.lastIndexOf("/") + 1;
    file = serverRoot.getFile(ref.substring(pathStart, pathEnd) + "x");
  });

  response.setHeader("Content-Type", "text/plain", false);
  response.write(file.path.substr(0, file.path.length-1));
}