How to use the serve-index.html function in serve-index

To help you get started, we’ve selected a few serve-index examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github coreyp1 / defiant / lib / plugin / http / response / serveDirectory.js View on Github external
else {
      // Restore the request to its original form.
      request.originalUrl = request.url = originalUrl;
      parseUrl(request);
    }
  }
}

/**
 * Because serveIndex() does not know about Defiant's directory structure,
 * it assumes that all the files' paths are relative to the domain.  We must
 * therefore intercept the function that prints the file listing and inject the
 * proper subdirectory path.
 */
const originalServeIndexHtml = serveIndex.html;
serveIndex.html = function() {
  if (arguments[0].__defiant_discarded) {
    if (arguments[4] == '/') {
      arguments[2].unshift('..');
    }
    arguments[4] = arguments[0].__defiant_discarded + arguments[4];
  }
  originalServeIndexHtml.apply(this, arguments);
};

module.exports = ServeDirectory;
github coreyp1 / defiant / lib / plugin / http / response / serveDirectory.js View on Github external
}
    else {
      // Restore the request to its original form.
      request.originalUrl = request.url = originalUrl;
      parseUrl(request);
    }
  }
}

/**
 * Because serveIndex() does not know about Defiant's directory structure,
 * it assumes that all the files' paths are relative to the domain.  We must
 * therefore intercept the function that prints the file listing and inject the
 * proper subdirectory path.
 */
const originalServeIndexHtml = serveIndex.html;
serveIndex.html = function() {
  if (arguments[0].__defiant_discarded) {
    if (arguments[4] == '/') {
      arguments[2].unshift('..');
    }
    arguments[4] = arguments[0].__defiant_discarded + arguments[4];
  }
  originalServeIndexHtml.apply(this, arguments);
};

module.exports = ServeDirectory;

serve-index

Serve directory listings

MIT
Latest version published 7 years ago

Package Health Score

70 / 100
Full package analysis

Popular serve-index functions