Skip to content

Instantly share code, notes, and snippets.

@anthify
Created September 16, 2019 13:53
Show Gist options
  • Save anthify/681345e2cff576c2ea1062c5fde3150c to your computer and use it in GitHub Desktop.
Save anthify/681345e2cff576c2ea1062c5fde3150c to your computer and use it in GitHub Desktop.
Takes path string and returns directory, filename, and extension in object.
export default path => ({
dir: path.substring(0, path.lastIndexOf('/')),
filename: path.substring(path.lastIndexOf('/') + 1, path.lastIndexOf('.')),
ext: path.substring(path.lastIndexOf('.') + 1)
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment