CodeQL library for JavaScript/TypeScript
codeql/javascript-all 2.6.5 (changelog, source)
Search

Member predicate FilePath::getPackagePrefix

Gets the NPM package name from the beginning of the given import path.

Has no result for paths starting with a . or /

For example:

  • foo/bar maps to foo
  • @example/foo/bar maps to @example/foo
  • ./foo maps to nothing.
string getPackagePrefix()