mirror of
https://github.com/github/codeql.git
synced 2025-12-18 18:10:39 +01:00
27 lines
883 B
Plaintext
27 lines
883 B
Plaintext
/** Provides a class for representing source maps. */
|
|
|
|
import javascript
|
|
|
|
/**
|
|
* A source mapping comment associating a source map with a file.
|
|
*/
|
|
class SourceMappingComment extends Comment {
|
|
/** The `url` is a `sourceMappingURL` embedded in this comment. */
|
|
string url;
|
|
|
|
SourceMappingComment() {
|
|
exists(string sourceMappingUrlRegex |
|
|
sourceMappingUrlRegex = "[@#]\\s*sourceMappingURL\\s*=\\s*(.*)\\s*"
|
|
|
|
|
// either a line comment whose entire text matches the regex...
|
|
url = this.(SlashSlashComment).getText().regexpCapture(sourceMappingUrlRegex, 1)
|
|
or
|
|
// ...or a block comment one of whose lines matches the regex
|
|
url = this.(SlashStarComment).getLine(_).regexpCapture("//" + sourceMappingUrlRegex, 1)
|
|
)
|
|
}
|
|
|
|
/** Gets the URL of the source map referenced by this comment. */
|
|
string getSourceMappingUrl() { result = url }
|
|
}
|