Skip to content

Commit

Permalink
[FIX] Use consistent RegExp to detect copyright comments (#275)
Browse files Browse the repository at this point in the history
Bundle Builder and AutoSplitter now use the same RegExp to detect copyrights that the uglifier task uses.

Fixes https://github.com/SAP/ui5-builder/issues/257 .
  • Loading branch information
codeworrior authored Jun 27, 2019
1 parent f27f903 commit bd7aa40
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/lbt/bundle/AutoSplitter.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const ModuleName = require("../utils/ModuleName");
const {SectionType} = require("./BundleDefinition");
const log = require("@ui5/logger").getLogger("lbt:bundle:AutoSplitter");

const copyrightCommentsPattern = /copyright|\(c\)|released under|license|\u00a9/i;
const copyrightCommentsPattern = /copyright|\(c\)(?:[0-9]+|\s+[0-9A-za-z])|released under|license|\u00a9/i;
const xmlHtmlPrePattern = /<(?:\w+:)?pre>/;

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/lbt/bundle/Builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const {SectionType} = require("./BundleDefinition");
const BundleWriter = require("./BundleWriter");
const log = require("@ui5/logger").getLogger("lbt:bundle:Builder");

const copyrightCommentsPattern = /copyright|\(c\)|released under|license|\u00a9/i;
const copyrightCommentsPattern = /copyright|\(c\)(?:[0-9]+|\s+[0-9A-za-z])|released under|license|\u00a9/i;
const xmlHtmlPrePattern = /<(?:\w+:)?pre>/;

const strReplacements = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
/*!
* ${copyright}
*/
console.log('HelloWorld');
console.log('HelloWorld');

/*
* function add(c) - this is still not implemented.
* @private
* @param {Component} c
* @name add
* This comment should be removed in the preload bundle although it contains the magic
* sequence "opening parenthesis - letter c - closing parenthesis" which usually indicates
* a c o p y r i g h t comment.
*/
12 changes: 11 additions & 1 deletion test/fixtures/sap.ui.core/main/src/sap/ui/core/some.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
/*!
* ${copyright}
*/
console.log('HelloWorld');
console.log('HelloWorld');

/*
* function add(c) - this is still not implemented.
* @private
* @param {Component} c
* @name add
* This comment should be removed in the preload bundle although it contains the magic
* sequence "opening parenthesis - letter c - closing parenthesis" which usually indicates
* a c o p y r i g h t comment.
*/

0 comments on commit bd7aa40

Please sign in to comment.