Created
June 20, 2017 12:40
-
-
Save jchaffin/ed7cc9d60ef8028c8989b136bfc47910 to your computer and use it in GitHub Desktop.
Splitting a relative path
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function splitPath(...relPath) { | |
return relPath.reduce( | |
(a, b) => (/\.?\//).test(b) ? a.concat(b) : a.concat('/', b), | |
rootDir | |
) | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment