From 81bed8d1883f249416f31faee04f265a2b3ed893 Mon Sep 17 00:00:00 2001 From: Joseph Date: Tue, 29 Dec 2015 12:52:11 -0500 Subject: [PATCH] Non-greedy capture of the source map path **Problem:** ``` var sourceMapRegExp = new RegExp(/(?:\/\/#|\/\/@|\/\*#)\s*sourceMappingURL=(.*)\s*(?:\*\/\s*)?$/); var match = '/*# sourceMappingURL=bootstrap.css.map */'.match(sourceMapRegExp); // ["/*# sourceMappingURL=bootstrap.css.map */", "bootstrap.css.map */"] ``` `match[1]` contains the trailing ` */` **Solution:** Make the capture for the path non-greedy. --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 25aad13..4a77b27 100644 --- a/index.js +++ b/index.js @@ -5,7 +5,7 @@ var sander = require( 'sander' ), var SourceNode = require( 'source-map' ).SourceNode; var SourceMapConsumer = require( 'source-map' ).SourceMapConsumer; -var sourceMapRegExp = new RegExp(/(?:\/\/#|\/\/@|\/\*#)\s*sourceMappingURL=(.*)\s*(?:\*\/\s*)?$/); +var sourceMapRegExp = new RegExp(/(?:\/\/#|\/\/@|\/\*#)\s*sourceMappingURL=(.*?)\s*(?:\*\/\s*)?$/); var extensionsRegExp = new RegExp(/(\.js|\.css)$/); module.exports = function concat ( inputdir, outputdir, options ) {