Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes for various paths #4

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function isglob(str, { strict = true } = {}) {
* @returns {String} static path section of glob
*/
function parent(str, { strict = false } = {}) {
str = path.normalize(str).replace(/\/|\\/, '/');
str = path.posix.normalize(str);

// special case for strings ending in enclosure containing path separator
if (/[\{\[].*[\/]*.*[\}\]]$/.test(str)) str += '/';
Expand All @@ -64,13 +64,17 @@ function parent(str, { strict = false } = {}) {
* @returns {Object} object with parsed path
*/
function globalyzer(pattern, opts = {}) {
if (pattern.startsWith('./')) pattern = pattern.substr(2);

let base = parent(pattern, opts);
let isGlob = isglob(pattern, opts);
let glob;

if (base != '.') {
glob = pattern.substr(base.length);
if (glob.startsWith('/')) glob = glob.substr(1);
// resolve `../` withing paths
glob = path.posix.normalize(glob)
} else {
glob = pattern;
}
Expand Down