Skip to content

Commit

Permalink
Render correct icon for parent path (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
leo authored May 30, 2018
1 parent f52a853 commit 7dfd727
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -299,13 +299,10 @@ const renderDirectory = async (current, acceptsJSON, handlers, config, paths) =>
if (stats.isDirectory()) {
details.base += slashSuffix;
details.relative += slashSuffix;

// This is not camelcase, as we might be sending
// the data away as JSON later, which shouldn't contain
// any camelcased keys.
details['is-directory'] = true;
details.type = 'directory';
} else {
details.ext = details.ext.split('.')[1] || 'txt';
details.type = 'file';

details.size = bytes(stats.size, {
unitSeparator: ' ',
Expand All @@ -328,8 +325,8 @@ const renderDirectory = async (current, acceptsJSON, handlers, config, paths) =>

// Sort to list directories first, then sort alphabetically
files = files.sort((a, b) => {
const aIsDir = a['is-directory'];
const bIsDir = b['is-directory'];
const aIsDir = a.type === 'directory';
const bIsDir = b.type === 'directory';

/* istanbul ignore next */
if (aIsDir && !bIsDir) {
Expand All @@ -354,9 +351,11 @@ const renderDirectory = async (current, acceptsJSON, handlers, config, paths) =>
const relative = path.join('/', ...directoryPath, '..', slashSuffix);

files.unshift({
type: 'directory',
base: '..',
relative,
title: relative
title: relative,
ext: ''
});
}

Expand Down

0 comments on commit 7dfd727

Please sign in to comment.