[Pkg-javascript-commits] [node-convert-source-map] 01/08: Imported Upstream version 1.1.1

Ross Gammon ross-guest at moszumanska.debian.org
Fri Aug 7 22:11:26 UTC 2015


This is an automated email from the git hooks/post-receive script.

ross-guest pushed a commit to branch master
in repository node-convert-source-map.

commit daee0dace8714d2d9a96a2b2d921d6b6b9b7fa61
Author: Ross Gammon <rossgammon at mail.dk>
Date:   Fri Aug 7 21:52:03 2015 +0200

    Imported Upstream version 1.1.1
---
 index.js              | 18 +++++++++++-------
 package.json          |  2 +-
 test/comment-regex.js | 47 ++++++++++++++++++++++++++---------------------
 3 files changed, 38 insertions(+), 29 deletions(-)

diff --git a/index.js b/index.js
index c3abefe..c340dde 100644
--- a/index.js
+++ b/index.js
@@ -5,7 +5,7 @@ var path = require('path');
 var commentRx = /^\s*\/(?:\/|\*)[@#]\s+sourceMappingURL=data:(?:application|text)\/json;(?:charset[:=]\S+;)?base64,(.*)$/mg;
 var mapFileCommentRx =
   // //# sourceMappingURL=foo.js.map                       /*# sourceMappingURL=foo.js.map */
-  /(?:\/\/[@#][ \t]+sourceMappingURL=(.+?)[ \t]*$)|(?:\/\*[@#][ \t]+sourceMappingURL=([^\*]+?)[ \t]*(?:\*\/){1}[ \t]*$)/mg
+  /(?:\/\/[@#][ \t]+sourceMappingURL=([^\s'"]+?)[ \t]*$)|(?:\/\*[@#][ \t]+sourceMappingURL=([^\*]+?)[ \t]*(?:\*\/){1}[ \t]*$)/mg
 
 function decodeBase64(base64) {
   return new Buffer(base64, 'base64').toString();
@@ -137,12 +137,16 @@ exports.removeMapFileComments = function (src) {
   return src.replace(mapFileCommentRx, '');
 };
 
-exports.__defineGetter__('commentRegex', function () {
-  commentRx.lastIndex = 0;
-  return commentRx; 
+Object.defineProperty(exports, 'commentRegex', {
+  get: function getCommentRegex () {
+    commentRx.lastIndex = 0;
+    return commentRx;
+  }
 });
 
-exports.__defineGetter__('mapFileCommentRegex', function () {
-  mapFileCommentRx.lastIndex = 0;
-  return mapFileCommentRx; 
+Object.defineProperty(exports, 'mapFileCommentRegex', {
+  get: function getMapFileCommentRegex () {
+    mapFileCommentRx.lastIndex = 0;
+    return mapFileCommentRx;
+  }
 });
diff --git a/package.json b/package.json
index 5ba1005..c9e3367 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
   "name": "convert-source-map",
-  "version": "1.0.0",
+  "version": "1.1.1",
   "description": "Converts a source-map from/to  different formats and allows adding/changing properties.",
   "main": "index.js",
   "scripts": {
diff --git a/test/comment-regex.js b/test/comment-regex.js
index 1dbdec1..16331cc 100644
--- a/test/comment-regex.js
+++ b/test/comment-regex.js
@@ -65,45 +65,50 @@ test('comment regex new spec - #', function (t) {
   t.end()
 })
 
-function mapFileComment(s) {
+function mapFileCommentWrap(s1, s2) {
   mapFileRx.lastIndex = 0;
-  return mapFileRx.test(s + 'sourceMappingURL=foo.js.map')
+  return mapFileRx.test(s1 + 'sourceMappingURL=foo.js.map' + s2)
 }
 
 test('mapFileComment regex old spec - @', function (t) {
 
   [ 
-    '//@ ',
-    '  //@ ',
-    '\t//@ ',
-    '///@ ',
-  ].forEach(function (x) { t.ok(mapFileComment(x), 'matches ' + x) });
+    ['//@ ', ''],
+    ['  //@ ', ''],                 // with leading spaces
+    ['\t//@ ', ''],                 // with a leading tab
+    ['///@ ', ''],                  // with a leading text
+    [';//@ ', ''],                  // with a leading text
+    ['return//@ ', ''],             // with a leading text
+  ].forEach(function (x) { t.ok(mapFileCommentWrap(x[0], x[1]), 'matches ' + x.join(' :: ')) });
 
   [ 
-    ' @// @',
-  ].forEach(function (x) { t.ok(!mapFileComment(x), 'does not match ' + x) })
+    [' @// @', ''],
+    ['var sm = "//@ ', '"'],        // not inside a string
+    ['var sm = \'//@ ', '\''],      // not inside a string
+    ['var sm = \' //@ ', '\''],     // not inside a string
+  ].forEach(function (x) { t.ok(!mapFileCommentWrap(x[0], x[1]), 'does not match ' + x.join(' :: ')) })
   t.end()
 })
 
 test('mapFileComment regex new spec - #', function (t) {
   [ 
-    '//@ ',
-    '  //@ ', // with leading space
-    '\t//@ ', // with leading tab
-    '//@ ', // with leading text
-  ].forEach(function (x) { t.ok(mapFileComment(x), 'matches ' + x) });
+    ['//# ', ''],
+    ['  //# ', ''],                 // with leading space
+    ['\t//# ', ''],                 // with leading tab
+    ['///# ', ''],                  // with leading text
+    [';//# ', ''],                  // with leading text
+    ['return//# ', ''],             // with leading text
+  ].forEach(function (x) { t.ok(mapFileCommentWrap(x[0], x[1]), 'matches ' + x.join(' :: ')) });
 
   [ 
-    ' #// #',
-  ].forEach(function (x) { t.ok(!mapFileComment(x), 'does not match ' + x) })
+    [' #// #', ''],
+    ['var sm = "//# ', '"'],        // not inside a string
+    ['var sm = \'//# ', '\''],      // not inside a string
+    ['var sm = \' //# ', '\''],     // not inside a string
+  ].forEach(function (x) { t.ok(!mapFileCommentWrap(x[0], x[1]), 'does not match ' + x.join(' :: ')) })
   t.end()
 })
 
-function mapFileCommentWrap(s1, s2) {
-  mapFileRx.lastIndex = 0;
-  return mapFileRx.test(s1 + 'sourceMappingURL=foo.js.map' + s2)
-}
-
 test('mapFileComment regex /* */ old spec - @', function (t) {
   [ [ '/*@ ', '*/' ]
   , ['  /*@ ', '  */ ' ]            // with leading spaces

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-convert-source-map.git



More information about the Pkg-javascript-commits mailing list