Skip to content

Commit

Permalink
fix image filtering case sensitivity
Browse files Browse the repository at this point in the history
  • Loading branch information
erquhart committed Nov 13, 2017
1 parent 1acdb8d commit 10c8203
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
11 changes: 7 additions & 4 deletions src/components/MediaLibrary/MediaLibrary.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import c from 'classnames';
import fuzzy from 'fuzzy';
import Waypoint from 'react-waypoint';
import Dialog from '../UI/Dialog';
import { resolvePath } from '../../lib/pathHelper';
import { resolvePath, fileExtension } from '../../lib/pathHelper';
import { changeDraftField } from '../../actions/entries';
import {
loadMedia as loadMediaAction,
Expand Down Expand Up @@ -53,16 +53,19 @@ class MediaLibrary extends React.Component {
/**
* Filter an array of file data to include only images.
*/
filterImages = files => {
return files ? files.filter(file => IMAGE_EXTENSIONS.includes(last(file.name.split('.')))) : [];
filterImages = (files = []) => {
return files.filter(file => {
const ext = fileExtension(file.name);
return IMAGE_EXTENSIONS.includes(ext);
});
};

/**
* Transform file data for table display.
*/
toTableData = files => {
const tableData = files && files.map(({ key, name, size, queryOrder, url, urlIsPublicPath }) => {
const ext = last(name.split('.'));
const ext = fileExtension(name);
return {
key,
name,
Expand Down
2 changes: 1 addition & 1 deletion src/lib/pathHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export function fileExtensionWithSeparator(p) {
if (i === -1 || i === 0) {
return '';
}
return p.substr(i);
return p.substr(i).toLowerCase();
}

/**
Expand Down

0 comments on commit 10c8203

Please sign in to comment.