Skip to content

Commit

Permalink
refactor: dirName
Browse files Browse the repository at this point in the history
          Use Node.js path.parse(pathString) ponyfill instead of
          custom code.
  • Loading branch information
munen committed Jun 14, 2022
1 parent 49ef5bf commit ddcb9d6
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/actions/sync_backend.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { createGitlabOAuth } from '../sync_backend_clients/gitlab_sync_backend_c

import { addSeconds } from 'date-fns';

import pathParse from 'path-parse';

export const signOut = () => (dispatch, getState) => {
switch (getState().syncBackend.get('client', {}).type) {
case 'WebDAV':
Expand Down Expand Up @@ -132,7 +134,7 @@ export const downloadFile = (path) => {
* @param {String} path Returns the directory name of `path`.
*/
function dirName(path) {
return path.substring(0, path.lastIndexOf('/') + 1);
return pathParse(path).dir;
}

export const createFile = (path, content) => {
Expand Down

0 comments on commit ddcb9d6

Please sign in to comment.