diff --git a/frontend/src/Store/Actions/interactiveImportActions.js b/frontend/src/Store/Actions/interactiveImportActions.js index 86cf06c5e..e9008bb85 100644 --- a/frontend/src/Store/Actions/interactiveImportActions.js +++ b/frontend/src/Store/Actions/interactiveImportActions.js @@ -5,6 +5,7 @@ import { sortDirections } from 'Helpers/Props'; import { createThunk, handleThunks } from 'Store/thunks'; import createAjaxRequest from 'Utilities/createAjaxRequest'; import updateSectionState from 'Utilities/State/updateSectionState'; +import naturalExpansion from 'Utilities/String/naturalExpansion'; import { set, update, updateItem } from './baseActions'; import createFetchHandler from './Creators/createFetchHandler'; import createHandleActions from './Creators/createHandleActions'; @@ -40,7 +41,7 @@ export const defaultState = { path: function(item, direction) { const path = item.path; - return path.toLowerCase(); + return naturalExpansion(path.toLowerCase()); }, artist: function(item, direction) { diff --git a/frontend/src/Utilities/String/naturalExpansion.js b/frontend/src/Utilities/String/naturalExpansion.js new file mode 100644 index 000000000..2cdd69b86 --- /dev/null +++ b/frontend/src/Utilities/String/naturalExpansion.js @@ -0,0 +1,11 @@ +const regex = /\d+/g; + +function naturalExpansion(input) { + if (!input) { + return ''; + } + + return input.replace(regex, (n) => n.padStart(8, '0')); +} + +export default naturalExpansion; diff --git a/frontend/src/Utilities/String/titleCase.js b/frontend/src/Utilities/String/titleCase.js index 5b76c10dd..03573b9e3 100644 --- a/frontend/src/Utilities/String/titleCase.js +++ b/frontend/src/Utilities/String/titleCase.js @@ -1,9 +1,11 @@ +const regex = /\b\w+/g; + function titleCase(input) { if (!input) { return ''; } - return input.replace(/\b\w+/g, (match) => { + return input.replace(regex, (match) => { return match.charAt(0).toUpperCase() + match.substr(1).toLowerCase(); }); }