Skip to content

Commit fb987e7

Browse files
committed
JS: Fix bad join
1 parent 6b9c629 commit fb987e7

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

javascript/ql/lib/semmle/javascript/dependencies/Dependencies.qll

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,11 @@ class ExternalNpmDependency extends NpmDependency {
151151
}
152152
}
153153

154+
pragma[nomagic]
155+
private string getImportedPackage(Import i) {
156+
result = i.getImportedPathString().(StringAsPath).getPackagePrefix()
157+
}
158+
154159
/**
155160
* Holds if import `i` may refer to the declared dependency `dep` of package `pkg`,
156161
* where the result value is the nesting depth of the file containing `i` within `pkg`.
@@ -159,7 +164,7 @@ private int importsDependency(Import i, NpmPackage pkg, NpmDependency dep) {
159164
exists(string name |
160165
dep = pkg.getPackageJson().getADependenciesObject(_).getPropValue(name) and
161166
not exists(i.getImportedModule()) and
162-
name = i.getImportedPathString().(StringAsPath).getPackagePrefix() and
167+
name = getImportedPackage(i) and
163168
i.getEnclosingModule() = pkg.getAModule() and
164169
result = distance(pkg, i.getFile())
165170
)

0 commit comments

Comments
 (0)