I'm trying to build a regexp or string split/replace that will return the filepath with the following tests
let filepath_1 = "./path/to/file.js"; // ./path/to/
let filepath_2 = "./path/to/file.min.js"; // ./path/to/
let filepath_3 = "./path/to/"; // ./path/to/
let filepath_4 = "./path/to"; // ./path/to
let filepath_5 = "/path/to"; // /path/to
let filepath_6 = "path/to"; // path/to
The slashes in the final results don't really matter, as long as the file is gone from the results and that it doesn't think that to is a file name..
My best effort so far is using file.replace(/[^\/]*$/, "") but it will remove the to in /path/to. I need some logic about the "." character