Skip to content
This repository has been archived by the owner on Jan 6, 2018. It is now read-only.

Fix stripping of statements on the first line and last line #10

Merged
merged 3 commits into from
Jan 9, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function StripFnLoader(source) {

var toStrip = query.strip.join('|');

var regexPattern = new RegExp('\\n[ \\t]*(' + toStrip + ')\\([^\\);]+\\)[ \\t]*[;\\n]', 'g');
var regexPattern = new RegExp('(?:^|\\n)[ \\t]*(' + toStrip + ')\\([^\\);]+\\)[ \\t]*(?:$|[;\\n])', 'g');

var transformed = source.replace(regexPattern, '\n');

Expand Down
2 changes: 2 additions & 0 deletions tests/fixtures/app/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
console.log('a console.log on the first line should get stripped');
/**
* Copyright 2015, Yahoo! Inc.
* Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.
Expand All @@ -10,3 +11,4 @@ var makeFoo = function (bar, baz) {
// This code would remain
return new Foo(bar, baz);
};
console.log('a console.log on the last line without a semicolon should get stripped')