Skip to content

Commit bcf398d

Browse files
Frédéric Misereygaearon
Frédéric Miserey
authored andcommittedMay 29, 2017
Fix detection of parent directory in ModuleScopePlugin (facebook#2405)
* Fix detection of parent directory * Correct parent directory detection fix Add windows specific path and extend to issuer path
1 parent 32f82c0 commit bcf398d

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed
 

‎packages/react-dev-utils/ModuleScopePlugin.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,10 @@ class ModuleScopePlugin {
3737
// Maybe an indexOf === 0 would be better?
3838
const relative = path.relative(appSrc, request.context.issuer);
3939
// If it's not in src/ or a subdirectory, not our request!
40-
if (relative[0] === '.') {
40+
if (
41+
relative.startsWith('../') ||
42+
relative.startsWith('..\\')
43+
) {
4144
return callback();
4245
}
4346
// Find path from src to the requested file
@@ -49,7 +52,10 @@ class ModuleScopePlugin {
4952
)
5053
);
5154
// Error if in a parent directory of src/
52-
if (requestRelative[0] === '.') {
55+
if (
56+
requestRelative.startsWith('../') ||
57+
requestRelative.startsWith('..\\')
58+
) {
5359
callback(
5460
new Error(
5561
`You attempted to import ${chalk.cyan(request.__innerRequest_request)} which falls outside of the project ${chalk.cyan('src/')} directory. ` +

0 commit comments

Comments
 (0)
Please sign in to comment.