Commit ccbb463
module: fix node_modules search path in edge case
The `p < nmLen` condition will fail when a module's name is end with
`node_modules` like `foo_node_modules`. The old logic will miss the
`foo_node_modules/node_modules` in node_modules paths.
TL;TR, a module named like `foo_node_modules` can't require any module
in the node_modules folder.
Fixes: #6679
PR-URL: #6670
Reviewed-By: Evan Lucas <evanlucas@me.com>1 parent 3f46b5c commit ccbb463Copy full SHA for ccbb463
File tree
Expand file treeCollapse file tree
2 files changed
+119
-19
lines changedOpen diff view settings
Filter options
- lib
- test/parallel
Expand file treeCollapse file tree
2 files changed
+119
-19
lines changedOpen diff view settings
Collapse file
+18-3Lines changed: 18 additions & 3 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
221 | 221 | |
222 | 222 | |
223 | 223 | |
| 224 | + |
| 225 | + |
| 226 | + |
| 227 | + |
| 228 | + |
| 229 | + |
| 230 | + |
224 | 231 | |
225 | 232 | |
226 | 233 | |
227 | 234 | |
228 | 235 | |
229 | | - |
| 236 | + |
| 237 | + |
| 238 | + |
| 239 | + |
| 240 | + |
| 241 | + |
230 | 242 | |
231 | 243 | |
232 | 244 | |
233 | 245 | |
234 | | - |
| 246 | + |
235 | 247 | |
236 | 248 | |
237 | 249 | |
| ||
265 | 277 | |
266 | 278 | |
267 | 279 | |
268 | | - |
| 280 | + |
269 | 281 | |
270 | 282 | |
271 | 283 | |
| ||
274 | 286 | |
275 | 287 | |
276 | 288 | |
| 289 | + |
| 290 | + |
| 291 | + |
277 | 292 | |
278 | 293 | |
279 | 294 | |
|
Collapse file
test/parallel/test-module-nodemodulepaths.js
Copy file name to clipboard+101-16Lines changed: 101 additions & 16 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
1 | 1 | |
2 | | - |
3 | | - |
4 | 2 | |
5 | | - |
| 3 | + |
| 4 | + |
| 5 | + |
6 | 6 | |
7 | | - |
| 7 | + |
| 8 | + |
| 9 | + |
| 10 | + |
| 11 | + |
| 12 | + |
| 13 | + |
| 14 | + |
| 15 | + |
| 16 | + |
| 17 | + |
| 18 | + |
| 19 | + |
| 20 | + |
| 21 | + |
| 22 | + |
| 23 | + |
| 24 | + |
| 25 | + |
| 26 | + |
| 27 | + |
| 28 | + |
| 29 | + |
| 30 | + |
| 31 | + |
| 32 | + |
| 33 | + |
| 34 | + |
| 35 | + |
| 36 | + |
| 37 | + |
| 38 | + |
| 39 | + |
| 40 | + |
| 41 | + |
| 42 | + |
| 43 | + |
| 44 | + |
| 45 | + |
| 46 | + |
| 47 | + |
| 48 | + |
| 49 | + |
| 50 | + |
| 51 | + |
| 52 | + |
| 53 | + |
| 54 | + |
| 55 | + |
| 56 | + |
| 57 | + |
| 58 | + |
| 59 | + |
| 60 | + |
| 61 | + |
| 62 | + |
| 63 | + |
| 64 | + |
| 65 | + |
| 66 | + |
| 67 | + |
| 68 | + |
| 69 | + |
| 70 | + |
| 71 | + |
| 72 | + |
| 73 | + |
| 74 | + |
| 75 | + |
| 76 | + |
| 77 | + |
| 78 | + |
| 79 | + |
| 80 | + |
| 81 | + |
| 82 | + |
| 83 | + |
| 84 | + |
| 85 | + |
| 86 | + |
| 87 | + |
| 88 | + |
| 89 | + |
| 90 | + |
| 91 | + |
| 92 | + |
| 93 | + |
| 94 | + |
| 95 | + |
| 96 | + |
| 97 | + |
| 98 | + |
8 | 99 | |
9 | | - |
10 | | - |
11 | | - |
12 | | - |
13 | | - |
14 | | - |
15 | | - |
16 | | - |
17 | | - |
18 | | - |
19 | | - |
20 | | - |
| 100 | + |
| 101 | + |
| 102 | + |
| 103 | + |
| 104 | + |
| 105 | + |
0 commit comments