Skip to content

Commit

Permalink
sort the json and plaintext response types as well
Browse files Browse the repository at this point in the history
  • Loading branch information
micahstubbs committed Jul 18, 2019
1 parent c8519c0 commit d6677e7
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,13 +217,13 @@ serveIndex.html = function _html(req, res, files, next, dir, showUp, icons, path
* Respond with application/json.
*/

serveIndex.json = function _json (req, res, files, next, dir, showUp, icons, path) {
serveIndex.json = function _json (req, res, files, next, dir, showUp, icons, path, sort) {
// stat all files
stat(path, files, function (err, fileList) {
if (err) return next(err)

// sort file list
fileList.sort(fileSort)
fileList.sort(sort)

// serialize
var body = JSON.stringify(fileList.map(function (file) {
Expand All @@ -238,13 +238,13 @@ serveIndex.json = function _json (req, res, files, next, dir, showUp, icons, pat
* Respond with text/plain.
*/

serveIndex.plain = function _plain (req, res, files, next, dir, showUp, icons, path) {
serveIndex.plain = function _plain (req, res, files, next, dir, showUp, icons, path, sort) {
// stat all files
stat(path, files, function (err, fileList) {
if (err) return next(err)

// sort file list
fileList.sort(fileSort)
fileList.sort(sort)

// serialize
var body = fileList.map(function (file) {
Expand Down

0 comments on commit d6677e7

Please sign in to comment.