Skip to content

Commit

Permalink
fix: Fix infinite loop inside scanDependency for relative paths start…
Browse files Browse the repository at this point in the history
…ing with a slash (#988)
  • Loading branch information
DesselBane authored Dec 30, 2021
1 parent 7d0f069 commit f35966e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/license-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ class LicensePlugin {

const scannedDirs = [];

while (dir && dir !== this._cwd) {
while (dir && dir !== this._cwd && !scannedDirs.includes(dir)) {
// Try the cache.
if (_.has(this._cache, dir)) {
pkg = this._cache[dir];
Expand Down
6 changes: 6 additions & 0 deletions test/license-plugin.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,12 @@ describe('LicensePlugin', () => {
expect(plugin._dependencies).toEqual({});
expect(existsSync).not.toHaveBeenCalled();
});

it('should not run into an infinite loop for relative paths starting with a slash', () => {
const id = '/abc/efg';

plugin.scanDependency(id);
});
});

describe('when adding dependencies', () => {
Expand Down

0 comments on commit f35966e

Please sign in to comment.