Skip to content

Commit

Permalink
normalize path segments to before doing comparisons
Browse files Browse the repository at this point in the history
  • Loading branch information
spalger committed Aug 12, 2016
1 parent f072e8a commit 7c3ea3d
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/rules/no-reaching-inside.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ module.exports = function noReachingInside(context) {
return step === '' || step === '.' || step === '..'
}

function normalizeSep(somePath) {
return somePath.split('\\').join('/')
}

function report(reachedTo, node) {
context.report({
node,
Expand All @@ -29,11 +33,11 @@ module.exports = function noReachingInside(context) {
}

function findNotAllowedReach(importPath, startingBase, join, ignoreStep) {
const steps = importPath.split('/').filter(Boolean)
const steps = normalizeSep(importPath).split('/').filter(Boolean)
let parentDir = startingBase
while (steps.length) {
const step = steps.shift()
parentDir = join(parentDir, step)
parentDir = normalizeSep(join(parentDir, step))

if (ignoreStep && ignoreStep(step)) continue

Expand Down

0 comments on commit 7c3ea3d

Please sign in to comment.