From 631b5d4df1f6d1e38a18d0c13feaff9113aa66cb Mon Sep 17 00:00:00 2001 From: Noah Rosenzweig Date: Sat, 21 Nov 2020 20:39:33 +0100 Subject: [PATCH] Improve build/generate-sri.js regex (#29753) When using single-quotes in config.yml, the previous regular expression in build/generate-cli.js wasn't working correctly, it was replacing ALL string values with hashes. Now both double- and single-quotes can be used in config.yml, and the RegExp will work as expected. Also, allow trailing whitespaces and empty ("") values to be matched. Co-authored-by: XhmikosR --- build/generate-sri.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/generate-sri.js b/build/generate-sri.js index 74264a2a0a..f5df661315 100644 --- a/build/generate-sri.js +++ b/build/generate-sri.js @@ -61,6 +61,6 @@ files.forEach(file => { console.log(`${file.configPropertyName}: ${integrity}`) - sh.sed('-i', new RegExp(`(\\s${file.configPropertyName}:\\s+"|')(\\S+)("|')`), `$1${integrity}$3`, configFile) + sh.sed('-i', new RegExp(`^(\\s+${file.configPropertyName}:\\s+["'])\\S*(["'])`), `$1${integrity}$2`, configFile) }) })