Minify: Accept single quotes in ace.js
's $$INCLUDE_*(...)
lines (#4513)
This fixes a bug introduced in commit
8e5fd19db2
.
This commit is contained in:
parent
c673a597f8
commit
b13004b25a
1 changed files with 11 additions and 7 deletions
|
@ -231,21 +231,25 @@ function getAceFile(callback) {
|
||||||
if (ERR(err, callback)) return;
|
if (ERR(err, callback)) return;
|
||||||
|
|
||||||
// Find all includes in ace.js and embed them
|
// Find all includes in ace.js and embed them
|
||||||
let founds = data.match(/\$\$INCLUDE_[a-zA-Z_]+\("[^"]*"\)/gi);
|
const filenames = [];
|
||||||
if (!settings.minify) {
|
if (settings.minify) {
|
||||||
founds = [];
|
const regex = /\$\$INCLUDE_[a-zA-Z_]+\((['"])([^'"]*)\1\)/gi;
|
||||||
|
// This logic can be simplified via String.prototype.matchAll() once support for Node.js
|
||||||
|
// v11.x and older is dropped.
|
||||||
|
let matches;
|
||||||
|
while ((matches = regex.exec(data)) != null) {
|
||||||
|
filenames.push(matches[2]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Always include the require kernel.
|
// Always include the require kernel.
|
||||||
founds.push('$$INCLUDE_JS("../static/js/require-kernel.js")');
|
filenames.push('../static/js/require-kernel.js');
|
||||||
|
|
||||||
data += ';\n';
|
data += ';\n';
|
||||||
data += 'Ace2Editor.EMBEDED = Ace2Editor.EMBEDED || {};\n';
|
data += 'Ace2Editor.EMBEDED = Ace2Editor.EMBEDED || {};\n';
|
||||||
|
|
||||||
// Request the contents of the included file on the server-side and write
|
// Request the contents of the included file on the server-side and write
|
||||||
// them into the file.
|
// them into the file.
|
||||||
async.forEach(founds, (item, callback) => {
|
async.forEach(filenames, (filename, callback) => {
|
||||||
const filename = item.match(/"([^"]*)"/)[1];
|
|
||||||
|
|
||||||
// Hostname "invalid.invalid" is a dummy value to allow parsing as a URI.
|
// Hostname "invalid.invalid" is a dummy value to allow parsing as a URI.
|
||||||
const baseURI = 'http://invalid.invalid';
|
const baseURI = 'http://invalid.invalid';
|
||||||
let resourceURI = baseURI + path.normalize(path.join('/static/', filename));
|
let resourceURI = baseURI + path.normalize(path.join('/static/', filename));
|
||||||
|
|
Loading…
Reference in a new issue