testing/mochitest/dynamic/getMyDirectory.sjs
author Till Schneidereit <tschneidereit@gmail.com>
Tue, 18 Sep 2012 22:11:37 +0200
changeset 113096 862f9cd7eb0bebf5fcc4e7a6a550bfbe0b1740db
parent 101260 ba9e4b81d7f60615ad111586a184e3bbcdb9a1c7
permissions -rw-r--r--
Bug 791850 - Lazily clone self-hosted methods installed via js_DefineFunction. r=luke

function handleRequest(request, response)
{
  var file;
  getObjectState("SERVER_ROOT", function(serverRoot)
  {
    var ref = request.getHeader("Referer").split("?")[0];
    // 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));
}