| Index: src/messages.js
|
| diff --git a/src/messages.js b/src/messages.js
|
| index de388214c7dffeec6b4ae71e353e29184ccb46cc..4fd7c4b411e252a7aaa19cfbcd57bec73511fd84 100644
|
| --- a/src/messages.js
|
| +++ b/src/messages.js
|
| @@ -497,6 +497,26 @@ Script.prototype.lineCount = function() {
|
| Script.prototype.nameOrSourceURL = function() {
|
| if (this.name)
|
| return this.name;
|
| + return this.findMagicComment("sourceURL");
|
| +}
|
| +
|
| +
|
| +/**
|
| + * Returns script source mapping url, if present.
|
| + *
|
| + * @return {?string} script source mapping url, if present.
|
| + */
|
| +Script.prototype.sourceMappingURL = function() {
|
| + return this.findMagicComment("sourceMappingURL");
|
| +}
|
| +
|
| +
|
| +/**
|
| + * Returns the value of the magic comment "//@ name=<value>", if present.
|
| + *
|
| + * @return {?string} the value of the magic comment, if present.
|
| + */
|
| +Script.prototype.findMagicComment = function(name) {
|
| // TODO(608): the spaces in a regexp below had to be escaped as \040
|
| // because this file is being processed by js2c whose handling of spaces
|
| // in regexps is broken. Also, ['"] are excluded from allowed URLs to
|
| @@ -504,21 +524,20 @@ Script.prototype.nameOrSourceURL = function() {
|
| // A better solution would be to detect these special comments in
|
| // the scanner/parser.
|
| var source = ToString(this.source);
|
| - var sourceUrlPos = %StringIndexOf(source, "sourceURL=", 0);
|
| - if (sourceUrlPos > 4) {
|
| - var sourceUrlPattern =
|
| - /\/\/@[\040\t]sourceURL=[\040\t]*([^\s\'\"]*)[\040\t]*$/gm;
|
| + var position = %StringIndexOf(source, name + "=", 0);
|
| + if (position > 4) {
|
| + var pattern = "\/\/@[ \t]" + name + "=[\040\t]*([^\\s\'\"]*)[\040\t]*$";
|
| + var regexp = new $RegExp(pattern, "gm");
|
| // Don't reuse lastMatchInfo here, so we create a new array with room
|
| // for four captures (array with length one longer than the index
|
| // of the fourth capture, where the numbering is zero-based).
|
| var matchInfo = new InternalArray(CAPTURE(3) + 1);
|
| var match =
|
| - %_RegExpExec(sourceUrlPattern, source, sourceUrlPos - 4, matchInfo);
|
| + %_RegExpExec(regexp, source, position - 4, matchInfo);
|
| if (match) {
|
| return SubString(source, matchInfo[CAPTURE(2)], matchInfo[CAPTURE(3)]);
|
| }
|
| }
|
| - return this.name;
|
| }
|
|
|
|
|
|
|