mirror of
https://github.com/github/codeql.git
synced 2026-04-26 01:05:15 +02:00
JS: do not resolve arbitrary extensions to JavaScript files
This commit is contained in:
@@ -88,6 +88,7 @@ abstract class Module extends TopLevel {
|
||||
result = f.getJavaScriptFile(path.getBaseName())
|
||||
or
|
||||
// If a js file was not found look for a file that compiles to js
|
||||
path.getExtension() = ".js" and
|
||||
not exists(f.getJavaScriptFile(path.getBaseName())) and
|
||||
result = f.getJavaScriptFile(path.getStem())
|
||||
)
|
||||
|
||||
@@ -128,6 +128,14 @@ abstract class PathString extends string {
|
||||
/** Gets the path of the parent folder of the folder or file this path refers to. */
|
||||
string getDirName() { result = this.regexpCapture(pathRegex(), 1) }
|
||||
|
||||
/**
|
||||
* Gets the extension of the folder or file this path refers to, that is, the suffix of the base name
|
||||
* starting at the last dot character, if there is one.
|
||||
*
|
||||
* Has no result if the base name does not contain a dot.
|
||||
*/
|
||||
string getExtension() { result = this.regexpCapture(pathRegex(), 4) }
|
||||
|
||||
/**
|
||||
* Gets the absolute path that the sub-path consisting of the first `n`
|
||||
* components of this path refers to when resolved relative to the
|
||||
@@ -208,6 +216,14 @@ abstract class PathExpr extends PathExprBase {
|
||||
/** Gets the stem, that is, base name without extension, of the folder or file this path refers to. */
|
||||
string getStem() { result = getValue().(PathString).getStem() }
|
||||
|
||||
/**
|
||||
* Gets the extension of the folder or file this path refers to, that is, the suffix of the base name
|
||||
* starting at the last dot character, if there is one.
|
||||
*
|
||||
* Has no result if the base name does not contain a dot.
|
||||
*/
|
||||
string getExtension() { result = getValue().(PathString).getExtension() }
|
||||
|
||||
/**
|
||||
* Gets the file or folder that the first `n` components of this path refer to
|
||||
* when resolved relative to the root folder of the given `priority`.
|
||||
|
||||
Reference in New Issue
Block a user