Skip to content

Commit 514f24d

Browse files
committed
Template formatting and remove unnecessary replace in toCode function
1 parent 5f84424 commit 514f24d

File tree

1 file changed

+5
-3
lines changed
  • lib/workbox/templates

1 file changed

+5
-3
lines changed

lib/workbox/templates/sw.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ function toCode(param) {
6969
let result = ''
7070
switch (typeof param) {
7171
case 'string':
72-
result += `'${param.replace(/\\/g, '\\\\').replace('"', '\\"').replace("'", "\\'")}'`
72+
result += `'${param.replace(/\\/g, '\\\\').replace("'", "\\'")}'`
7373
break
7474
case 'number':
7575
case 'boolean':
@@ -98,12 +98,14 @@ options.runtimeCaching.forEach(r => {
9898
// process plugins field
9999
if (r.strategyOptions.plugins) {
100100
let pluginsChunk = 'plugins:['
101-
pluginsChunk += r.strategyOptions.plugins.map(p => 'new workbox.' + pluginModules[p.use] + '(' + p.config.map(toCode).join(',') + ')').join(',')
101+
pluginsChunk += r.strategyOptions.plugins
102+
.map(p => `new workbox.${pluginModules[p.use]}(${p.config.map(toCode).join(',')})`)
103+
.join(',')
102104
pluginsChunk += ']'
103105
strategyOptionsCodeChunks.push(pluginsChunk)
104106
}
105107

106-
// process the rest fields
108+
// process the remaining fields
107109
const options = Object.assign({}, r.strategyOptions)
108110
delete options.plugins
109111
const remainingOptionsCode = toCode(options).slice(1, -1)

0 commit comments

Comments
 (0)