From e472ecce1a0af0e7fb781cd12e048ba86cbecc33 Mon Sep 17 00:00:00 2001 From: guybedford Date: Wed, 3 Feb 2016 15:04:01 +0200 Subject: [PATCH] correct System.register regex (#1071) --- lib/register.js | 2 +- test/test.js | 7 +++++++ test/tests/register-regex-2.js | 15 +++++++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 test/tests/register-regex-2.js diff --git a/lib/register.js b/lib/register.js index 17cc6298..e94ba5fe 100644 --- a/lib/register.js +++ b/lib/register.js @@ -51,7 +51,7 @@ * */ -var leadingCommentAndMetaRegEx = /^\s*(\/\*[^\*]*(\*(?!\/)[^\*]*)*\*\/|\s*\/\/[^\n]*|\s*"[^"]+"\s*;?|\s*'[^']+'\s*;?)*\s*/; +var leadingCommentAndMetaRegEx = /^(\s*\/\*[^\*]*(\*(?!\/)[^\*]*)*\*\/|\s*\/\/[^\n]*|\s*"[^"]+"\s*;?|\s*'[^']+'\s*;?)*\s*/; function detectRegisterFormat(source) { var leadingCommentAndMeta = source.match(leadingCommentAndMetaRegEx); return leadingCommentAndMeta && source.substr(leadingCommentAndMeta[0].length, 15) == 'System.register'; diff --git a/test/test.js b/test/test.js index dea4e171..f509815f 100644 --- a/test/test.js +++ b/test/test.js @@ -514,6 +514,13 @@ asyncTest('System.register regex test', function() { }, err); }); +asyncTest('System.register regex test 2', function() { + System['import']('tests/register-regex-2.js').then(function(m) { + ok(m); + start(); + }, err); +}); + asyncTest('System.register module name arg', function() { System['import']('tests/module-name.js').then(function(m) { ok(m.name == System.baseURL + 'tests/module-name.js'); diff --git a/test/tests/register-regex-2.js b/test/tests/register-regex-2.js new file mode 100644 index 00000000..3715b11e --- /dev/null +++ b/test/tests/register-regex-2.js @@ -0,0 +1,15 @@ +/** + * @file file comment + * ... + */ + +/** + * module comment + * ... + */ +System.register([], function() { + return { + setters: [], + execute: function() {} + }; +}); \ No newline at end of file