]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
Improve build/generate-sri.js regex (#29753)
authorNoah Rosenzweig <rosenzweig.noah@gmail.com>
Sat, 21 Nov 2020 19:39:33 +0000 (20:39 +0100)
committerXhmikosR <xhmikosr@gmail.com>
Tue, 24 Nov 2020 06:40:11 +0000 (08:40 +0200)
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 <xhmikosr@gmail.com>
build/generate-sri.js

index 74264a2a0aa6443213047474e42c5c8eba1a5d1b..f5df6613158bef8fda8665c624a43562c831b10d 100644 (file)
@@ -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)
   })
 })